Please note: The code on this page is submitted by members of the FoxyCart community, and may not verified by FoxyCart.com LLC in any way, shape, or form. Please double check the code before installing. If you need help with it please post in our forum, but if we cannot offer assistance (due to unfamiliarity with this particular system or language) we apologize in advance.
Because ASP.NET wraps the entire <body>
section in a <form>
tag, you cannot use forms in your pages, nor will the FoxyCart javascript behave as desired.
Coming soon.
Copy or download the following code and save it on your server as form_fake.js
. Put a <script>
tag referencing it in the <head>
section of your HTML, after your jQuery or foxycart.complete.js
(or foxycart.js
) call:
function form_fake(link) { link_parent = jQuery(link).closest('div.foxycart_form'); if (link_parent.length < 1) return false; // console.info(link); // console.info(link_parent); href = 'https://' + storedomain + '/cart?' + jQuery(link_parent).find('*').serialize(); jQuery(link).attr('href', href); // console.info(jQuery(link).attr('href')); return true; } jQuery(document).ready(function($) { // Initialize it on pageload form_fake($('div.foxycart_form a.foxycart_submit')); // Update it on every change $('div.foxycart_form *').change(function(){ form_fake($(this).closest('div.foxycart_form').find('a.foxycart_submit')); }); }); // Ensure it gets run prior to a cart-add request fcc.events.cart.preprocess.add(function(e){ form_fake(e); });
<form>
element, make it a div.foxycart_form
element. Remove the form-specific attributes like action
, method
, and accept-charset
.input[type=submit]
elements (or anything comparable) to a.foxycart_submit
.a.foxycart_submit
link does not have any parameters on it. Anything that the link itself has will be blown away when the script runs. All values must be in input
or select
or other form elements.So your HTML should look something like this:
<div class="foxycart_form"> <input type="hidden" name="name" value="Seats of CRM" /> <input type="hidden" name="discount_quantity_amount" value="Volume Discount{10-5}" /> <input type="hidden" name="price" value="54.99" /> <select name="sub_frequency"> <option value="1m">Monthly</option> <option value="1y{p:604.89}">Annual - 1st Month Free</option> </select> <a href="https://YOURDOMAIN.foxycart.com/cart" class="foxycart_submit">Submit</a> </div>
Copy or download the following code and save it on your server as form_fake.js
. Put a <script>
tag referencing it in the <head>
section of your HTML, after your jQuery or foxycart_includes.js
(or foxycart.js
) call:
function form_fake(link) { link_parent = jQuery(link).closest('div.foxycart_form'); if (link_parent.length < 1) return false; // console.info(link); // console.info(link_parent); href = 'https://' + FoxyDomain + '/cart?' + jQuery(link_parent).find('*').serialize() + fc_AddSession(); jQuery(link).attr('href', href); // console.info(jQuery(link).attr('href')); } jQuery(document).ready(function($){ form_fake($('div.foxycart_form a.foxycart_submit')); $('div.foxycart_form a.foxycart_submit').click(function(){ form_fake($(this)); }); $('div.foxycart_form *').change(function(){ form_fake($(this).closest('div.foxycart_form').find('a.foxycart_submit')); }); });
form.foxycart
elements to div.foxycart_form
elements. Remove the form-specific attributes like action
, method
, and accept-charset
.input[type=submit]
elements (or anything comparable) to a.foxycart.foxycart_submit
.a.foxycart_submit
link does not have any parameters on it. Anything that the link itself has will be blown away when the script runs. All values must be in input
or select
or other form elements.So your HTML should look something like this:
<div class="foxycart_form"> <input type="hidden" name="name" value="Seats of CRM" /> <input type="hidden" name="discount_quantity_amount" value="Volume Discount{10-5}" /> <input type="hidden" name="price" value="54.99" /> <select name="sub_frequency"> <option value="1m">Monthly</option> <option value="1y{p:604.89}">Annual - 1st Month Free</option> </select> <a href="https://YOURDOMAIN.foxycart.com/cart" class="foxycart foxycart_submit">Submit</a> </div>