This is an old revision of the document!
- type:
- snippet
- category:
- checkout
- name:
- Adding a gift-wrapping checkbox to the checkout.
- reference:
- https://forum.foxycart.com/discussion/3214
- date:
- 2011-05-27
Adding a gift-wrapping checkbox to the checkout
Add the code below:
<script type="text/javascript" charset="utf-8"> function addGiftWrapCost() { if (jQuery("#gift_wrap").is(":checked")) { FC.checkout.config.orderShipping = FC.checkout.config.orderShipping + 6; jQuery("#gift_wrap_details_container").show(); FC.checkout.config.giftWrappingApplied = true; } else { if (FC.checkout.config.giftWrappingApplied) { FC.checkout.config.orderShipping = Math.max(0,(FC.checkout.config.orderShipping-6)); jQuery("#gift_wrap_details_container").hide(); FC.checkout.config.giftWrappingApplied = false; } } } jQuery(document).ready(function(){ FC.checkout.config.giftWrappingApplied = false; addGiftWrapCost(); FC.checkout.overload("updatePriceDisplay", "addGiftWrapCost", null); jQuery("#gift_wrap").click(function(){ FC.checkout.updatePriceDisplay(); }); }); </script>
With this as your custom checkout stuff:
<input type="checkbox" name="gift_wrap" id="gift_wrap" value="yes" class="fc_checkbox" checked="checked" /> <label for="gift_wrap">Should we gift wrap this? ($6.00)</label><br/> <div id="gift_wrap_details_container" style="display:none;"> Gift Wrap Messsage: <input type="text" value="" id="gift_wrap_details" name="gift_wrap_details"/> </div>