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.
LightCMS is a content management system for web designers. Design sites, upload them to our content management system, and deploy world-class websites your clients can manage themselves.
Assumptions:
<head>
section of the template. Make sure to change YOURDOMAIN
to the appropriate subdomain.<!-- BEGIN FOXYCART + LIGHTCMS CODE --> <script type="text/javascript" charset="utf-8"> jQuery(document).ready(function(){ // Unbind any elements that already have the foxybox event jQuery('a.foxycart').unbind('click'); // Re-bind links, including links generated by Light's link tool fc_tb_init('a[href*='+FoxyDomain+']'); }); </script> <!-- END FOXYCART + LIGHTCMS CODE -->
Make sure you change the YOURDOMAIN
to the appropriate store domain. This makes your “add to cart” links appear inside the FoxyBox/Thickbox overlay.
https://YOURDOMAIN.foxycart.com/cart?name=A Red Baloon&price=9.99
YOURDOMAIN
to your store's subdomain.Please see the instructions on faking forms using javascript.
When adding a form to a product page on your Light CMS page, you will have a conflict. Light CMS adds an open form tag (<form>
) after the opening <body>
tag and a close form tag (</form>
) before the closing </body>
tag. Since this is added by Light CMS, if you attempt to add a form on your product page, you will have a conflict resulting in your form not working correctly.
What follows is a small bit of jQuery to allow you to use a text input element to allow a user-editable price field. This could be extremely useful for creating donation forms, for example.
<script>
tags and paste it into a new file on your own server and reference it there.<script type="text/javascript" charset="utf-8"> jQuery(document).ready(function(){ // Set the event for all input[name=price] fields inside of div.form elements jQuery('div.form input[name=price]').change(function(){ // Find and set the elements var this_form = jQuery(this).parent('div.form')[0]; var this_link = jQuery(this_form).children('a')[0]; var price = jQuery(this).val(); // Strip out the $ in case the user adds it, and format it as a currency price = price.replace('$', ''); price = parseFloat(price); price = fc_CurrencyFormatted(price); jQuery(this).val(price); // Replace the current price in the add-to-cart link with the newly entered price if (parseFloat(price)) { var this_href = jQuery(this_link).attr('href'); var this_href_new = this_href.replace(/price=[0-9.]+/, 'price='+price); jQuery(this_link).attr('href', this_href_new); } else { alert('Please enter a numeric value for your donation.'); return false; } }); }); </script>
<div class="form"> <input type="text" name="price" value="5.00" /> <a href="https://YOURDOMAIN.FOXYCART.TLD/cart?name=Product Name&price=5">Add to Cart</a> </div>
If you compare the code above to the normal form used for Foxy Cart forms, you will notice a few things:
<form>
and </form>
) and replaced them with <div>
tags. div.form
doesn't require a class of foxycart
.input
elements or a submit input
button as you would with a form. Instead you're basically just using a standard link.The basic idea is covered here, but there are a few LightCMS specific considerations:
https
, which makes things work MUCH better, as it can avoid caching the dozen or so (fairly large) CSS and JavaScript files.styles.css
or /templates/styles.css
) call them using a full path like https://example.publishpath.tld/Websites/path/to/things.ext
favicon
, as described here.You'll need to manually remove the form tag that follows the opening body tag:
<body><form name="frm" method="post" action="http://YOURWEBSITE/checkouttemplate" id="frm" enctype="multipart/form-data">
and
</form> </body>