type:
snippet
category:
shipping
name:
Automatically selecting returned shipping rate
versions:
0.6.0, 0.7.0, 0.7.1, 0.7.2, 1.0, 1.1
reference:
http://forum.foxycart.com/discussion/5498/set-default-shipping-method
tags:
snippets, advance shipping, liverates
date:
2012-02-05

Automatically selecting returned shipping rate

This script automatically selects the first returned shipping option with live rates, and updates the total price of the checkout accordingly.

Step 1: Add Javascript

Paste the following code right before the closing </head> tag of your checkout template:

<script type="text/javascript">
jQuery(document).ready(function() {
  jQuery(document).ajaxComplete(function(event, request, settings) {
    if (settings.url.indexOf('GetShippingCost') != -1) {
      $("#fc_shipping_methods_inner input[type='radio']:first").prop("checked", true);
      FC.checkout.updatePrice(i);
    }
  });
});
</script>

Site Tools