The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

Opting out of insurance on an order

matt633matt633 Member
in Help edited April 2014
I'm looking for help regarding a customer request - they would like to have a handling percentage added to the order total (no problem) BUT they want to give the customer the option to "opt out". They will be using live shipping rates - I've read in places that there's no way to modify a live shipping rate, but wondering if you ever run into this before.

I'm looking to do something of this nature ( I know I've probably got a bunch of the wrapping functions incorrect, but I'm piecing this together from other posts):

<script type="text/javascript">
function updateMyShippingCost() {
// Grab current shipping cost (from live rates)
var shippingCost = FC.checkout.config.orderShipping;

// Update the shipping cost with the updated figures
FC.checkout.config.orderShipping = shippingCost;
}


if (jQuery("input[name='Insurance']").is(":checked")) {
shippingCost += 0.03 * amount;
}
else {
shippingCost += 0.0 * amount;
}


jQuery(document).ready(function(){
// set the custom function to run before the updatePriceDisplay function
FC.checkout.overload("updatePriceDisplay", "updateMyShippingCost", null);
});
</script>

Thanks for whatever advice you might have here.
-Matt
Comments
  • fc_adamfc_adam FoxyCart Team
    @matt633,

    It's definitely possible to achieve - but requires some javascript like you've realised.

    What you've got there should be fine - but with two modifications - you need to actually remove the handling fee from the shipping cost, rather than just adding 0 instead. Otherwise the customers will opt out but won't see the shipping cost drop.

    Also, instead of running it before "updatePriceDisplay", I'd recommend attaching your function as a change event handler to the checkbox, and actually calling "FC.checkout.updatePriceDisplay() at the end of your function.
Sign In or Register to comment.