type:
snippet
category:
shipping
name:
Conditional free shipping with live rates
versions:
0.6.0,
0.7.0,
0.7.1,
0.7.2,
1.0
reference:
http://forum.foxycart.com/comments.php?DiscussionID=1531
tags:
snippets,
advance
date:
2011-05-25

Conditional free shipping with live rates

When using live rates, you may want to include a free shipping option for customers who reach a certain threshold - like a certain number of products, or from a certain country.

Step 1: Enable free shipping option

Under 'Shipping' in the administration, check 'Use custom' and 'Free ground shipping' under 'Custom Options', and update the settings. You can also rename it to be whatever you want from within the 'Languages' section of the administration.

Step 2: Add Javascript

Paste the following code right before the closing </head> tag of your checkout template, updating the logic to match what you're checking against:

<script type="text/javascript" charset="utf-8" >
var myCustomShipping = function() {
  if (fc_json.total_price < 150) {
    // if the requirements *are not* met, then remove the free shipping option.
    jQuery("label[for='shipping_service_60']").remove();
  }
}
 
jQuery(document).ready(function() {
  jQuery(document).ajaxComplete(function(event, request, settings) {
    myCustomShipping();
  });
});
</script>

Related Forum Discussions

snippets/shipping/conditional_free_shipping_with_live_rates.txt · Last modified: 2013/03/20 21:16 by adam
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki