This is an old revision of the document!


type:
snippet
category:
checkout
name:
Adding a gift-wrapping checkbox to the checkout.
reference:
http://forum.foxycart.com/comments.php?DiscussionID=3214&page=1

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();
} else {
FC.checkout.config.orderShipping = Math.max(0,(FC.checkout.config.orderShipping-6));
jQuery("#gift_wrap_details_container").hide();
}
}
jQuery(document).ready(function(){
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>

Site Tools