Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
snippets:shipping:breaking_shipments_over_maximum_weight_into_smaller_packages [2011/12/24 01:43] – [Data entry] adamsnippets:shipping:breaking_shipments_over_maximum_weight_into_smaller_packages [2017/04/26 07:02] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ---- dataentry snippet ---- ---- dataentry snippet ----
-type          : snippet #do not change this line +type          : snippet # do not change this line 
-category      : shipping #mention the category like 'shipping', 'checkout' etc +category      : shipping # mention the category like 'shipping', 'checkout' etc 
-name          : Breaking shipments over the maximum weight into smaller packages #the name of the snippet +name          : Breaking shipments over the maximum weight into smaller packages # the name of the snippet 
-description   :  #description about snippet +description   :  # description about snippet 
-versions_tags : 0.6.0, 0.7.0, 0.7.1, 0.7.2 #compatible versions +versions_tags : 0.6.0, 0.7.0, 0.7.1, 0.7.2, 1.0 # compatible versions 
-reference_url : http://forum.foxycart.com/comments.php?DiscussionID=4365&page=1 #Comment_33091           # External link +reference_url : https://forum.foxycart.com/discussion/4365# Comment_33091           # External link 
-tags_tags     : snippets, shipping, weight, advance #tags, separated by commas. +tags_tags     : snippets, shipping, weight, advance # tags, separated by commas. 
-date_dt       : 2011-05-27 #the date in YYYY-MM-DD format+date_dt       : 2011-05-27 # the date in YYYY-MM-DD format
 ---- ----
 +
 ===== Breaking shipments over the maximum weight into smaller packages ===== ===== Breaking shipments over the maximum weight into smaller packages =====
  
-For some stores shipping larger products, it can be possible to go over the weight limit for the shipping provider, in which case your customers just receive an error saying that the rates can't be calculatedThis script works around that by setting the shipment weight to smaller acceptable weight and calculating the shipping by the returned rate for the smaller package multiplied by how many of the smaller packages there areNot perfect, but a great work around until more powerful shipping is implemented in an upcoming version.+<WRAP center round important 80%> 
 +**Using version 2.0?** There is new snippet available for our latest version, [[v:2.0:snippets:breaking_large_shipments_into_multiple|available from here]]. 
 +</WRAP>
  
 +<WRAP center round important 60%>
 +**Versions 0.7.1 and older**: Note that applying javascript shipping modifications using either live or flat rates where you are setting custom values has been found to not work as expected for subscription based products where you need the shipping to apply to each subscription renewal. A fix is in place for versions 0.7.2 and newer.
 +</WRAP>
 +
 +For some stores shipping larger products, it can be possible to go over the weight limit for the shipping provider, in which case your customers just receive an error saying that the rates can't be calculated. This script works around that by setting the shipment weight to a smaller acceptable weight and calculating the shipping by the returned rate for the smaller package multiplied by how many of the smaller packages there are. Not perfect, but a great work around until more powerful shipping is implemented in an upcoming version.
 ==== Step 1: Add the javascript ==== ==== Step 1: Add the javascript ====
  
 Paste the following code above the closing </head> tag in your **checkout** template: Paste the following code above the closing </head> tag in your **checkout** template:
  
 +=== FoxyCart version 0.6.0+ ===
 <code javascript> <code javascript>
 <script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
Line 22: Line 31:
   maximum_weight = 70;   maximum_weight = 70;
   package_weight = 30;   package_weight = 30;
 +  
 +  // set custom packages to the expected default of 1
 +  custom_packages = 1;
      
   if (fc_json.total_weight > maximum_weight) {   if (fc_json.total_weight > maximum_weight) {
Line 29: Line 41:
   }   }
      
-  jQuery("#fc_shipping_methods_inner").ajaxComplete(function(event, request, settings) {+  jQuery(document).ajaxComplete(function(event, request, settings) {
     if (settings.url.indexOf('GetShippingCost') != -1) {     if (settings.url.indexOf('GetShippingCost') != -1) {
       jQuery("#fc_shipping_methods_inner input.fc_radio").each(function() {       jQuery("#fc_shipping_methods_inner input.fc_radio").each(function() {
Line 42: Line 54:
 </code>  </code> 
  
-To customise the script, edit the two variables at the start of the script called 'maximum_weight' (set to the heaviest package your shipping provider will return rates forand 'package_weight(the size of the smaller package you will send larger shipments in). Obviously'package_weight' must be smaller than 'maximum_weight' and should take into account the products your shipping. For example, if the products you're shipping are 30lb and 40lb, and the shipping maximum is 70lb, set your package_weight to 40lb.+=== FoxyCart version 0.7.2+ === 
 +<code javascript> 
 +<script type="text/javascript" charset="utf-8"> 
 +jQuery(document).ready(function() { 
 +  maximum_weight = 70; 
 +  package_weight = 30; 
 +   
 +  // set custom packages to the expected default of 1 
 +  custom_packages = 1; 
 +   
 +  if (fc_json.total_weight > maximum_weight
 +    custom_packages = fc_json.total_weight/package_weight
 +     
 +    FC.checkout.config.orderLiveRateShipmentWeight = package_weight; 
 +  } 
 +   
 +  jQuery(document).ajaxComplete(function(eventrequestsettings) { 
 +    if (settings.url.indexOf('GetShippingCost') != -1) { 
 +      jQuery("#fc_shipping_methods_inner input.fc_radio").each(function() { 
 +        var rate = jQuery(this).val().split("|"); 
 +        var adjusted_total = parseFloat(rate[1]) * custom_packages; 
 +        jQuery(this).val(rate[0] + "|" + adjusted_total).siblings(".fc_shipping_cost").html(FC.formatter.currency(adjusted_total, true)); 
 +      }); 
 +    } 
 +  }); 
 +}); 
 +</script> 
 +</code> 
  
 +To customise the script, edit the two variables at the start of the script called 'maximum_weight' (set to the heaviest package your shipping provider will return rates for) and 'package_weight' (the size of the smaller package you will send larger shipments in). Obviously, 'package_weight' must be smaller than 'maximum_weight' and should take into account the products your shipping. For example, if the products you're shipping are 30lb and 40lb, and the shipping maximum is 70lb, set your package_weight to 40lb.
 ==== What does this script do? ==== ==== What does this script do? ====
  

Site Tools