Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| snippets:shipping:breaking_shipments_over_maximum_weight_into_smaller_packages [2011/12/24 01:43] – [Data entry] adam | snippets: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 | + | category |
| - | 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 |
| - | 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:// | + | reference_url : https:// |
| - | tags_tags | + | tags_tags |
| - | date_dt | + | date_dt |
| ---- | ---- | ||
| + | |||
| ===== 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 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. | + | <WRAP center round important 80%> |
| + | **Using version 2.0?** There is a new snippet available | ||
| + | </ | ||
| + | <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. | ||
| + | </ | ||
| + | |||
| + | 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 </ | Paste the following code above the closing </ | ||
| + | === FoxyCart version 0.6.0+ === | ||
| <code javascript> | <code javascript> | ||
| <script type=" | <script type=" | ||
| 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("# | + | jQuery(document).ajaxComplete(function(event, |
| if (settings.url.indexOf(' | if (settings.url.indexOf(' | ||
| jQuery("# | jQuery("# | ||
| Line 42: | Line 54: | ||
| </ | </ | ||
| - | To customise the script, edit the two variables at the start of the script called ' | + | === FoxyCart version 0.7.2+ === |
| + | <code javascript> | ||
| + | <script | ||
| + | jQuery(document).ready(function() { | ||
| + | maximum_weight = 70; | ||
| + | package_weight = 30; | ||
| + | |||
| + | // set custom packages | ||
| + | custom_packages = 1; | ||
| + | |||
| + | if (fc_json.total_weight > maximum_weight) { | ||
| + | custom_packages = fc_json.total_weight/ | ||
| + | |||
| + | FC.checkout.config.orderLiveRateShipmentWeight = package_weight; | ||
| + | } | ||
| + | |||
| + | jQuery(document).ajaxComplete(function(event, request, settings) { | ||
| + | | ||
| + | jQuery("# | ||
| + | var rate = jQuery(this).val().split(" | ||
| + | var adjusted_total = parseFloat(rate[1]) * custom_packages; | ||
| + | jQuery(this).val(rate[0] + " | ||
| + | }); | ||
| + | } | ||
| + | }); | ||
| + | }); | ||
| + | </ | ||
| + | </ | ||
| + | To customise the script, edit the two variables at the start of the script called ' | ||
| ==== What does this script do? ==== | ==== What does this script do? ==== | ||