PDA

View Full Version : MultiGeoZone MultiTable Shipping



michael_s
11-18-2009, 10:02 PM
I've made a small change to the MZMT script to calculate shipping based on the cost per additional weight. e.g. most post offices will list the price for the first 0.5kg, 1kg, and after that, the cost will be for each additional 0.5kg.

For this change, I've used the * symbol to indicate that this will be the cost per additional weight. This MUST be the last item on the rate table.

e.g. your MZMT rate table will look like this:
.01:$3,1.5:$4,2:0.5*

To explain the above table, the cost from 0.1 lb to 1.49 lb is $3, 1.5 lb to 1.99 lb costs $4, then each additional 0.5 lb (2 lb - 1.5 lb) is an additional $0.50

To change it so that it is calculated based on 1 lb, just change the table so that the last two fields is a difference of 1 instead of 0.5.
Example rate table:
.01:$3,1:$4,2:0.5*


Changes made:
Line 152, look for:
$shipping_factor = $table_cost[$i+1];

Add the following after the line:
$previous_weight = $table_cost[$i-2];
$previous_cost = $table_cost[$i-1];
$current_weight = $table_cost[$i];



Line 160, look for:
$shipping = ((($this->order_total*10)/10)*((str_replace('%', '', $shipping_factor))/100));

Add the following after the line:
} elseif (substr_count($shipping_factor, '*') > 0) {
$weight_measure = $current_weight - $previous_weight; //Find out how much is each additional factor eg. additional 0.5 lb or additional 1 lb
$add_cost = ceil((($this->order_total - $previous_weight)/$weight_measure)) * (str_replace('*', '', $shipping_factor)); //How many additional shipping cost
$shipping = str_replace('$', '', $previous_cost) + $add_cost;


You can also just replace the mzmt.php with the included file.

More... (http://addons.oscommerce.com/info/2571)