Multiple Tare Weights Zencart

Please LogIn to Reply!

Post By: guest | 01-16-2013 07:57 Reply

Question




Hello,

I saw a similar question posted in a thread from a couple of years ago, but there was never any resolution to the problem. I'm hoping for a little more success this time.



I understand tare weights as well as the often misunderstood "larger packages" setting & multiple boxes per shipment.



As I have it now, the tare weight applies one uniform weight adjustment to all orders. I'm wanting to get a little more sophisticated than that - to get the shipping rates dialed in more accurately.



Neither the uniform percentage nor the added weight really works in an ideal manner for me.



What I would like:

The ability to apply one tare to orders below a certain weight threshold and a different tare to orders above that threshold.



For example:

I would like all orders with a weight below 1.5 lbs to get a 3oz tare. All orders above 1.5 lbs should get a 9oz tare.



(The larger packages setting does not do this.)



I am not shy about messing around with the code if anyone has any good ideas for this.

Thanks so much.






Answers




The Tare is added in the shipping class in the function calculate_boxes_weight_and_tare() ...



You can alter the amount being used for this calculation in there ...









Thank you Ajeh.



What I came up with is crude, but it works for me.

If anyone else was interested in this, all I did was hardcode the tare rules into the calculation. After tweaking it for a while, I wanted all orders with a weight less than 1.75 lbs to use a 0.375 lb tare weight. Everything else will get a 0.57 lb tare weight.



The file we're looking for is: /includes/classes/shipping.php.



Find code:


Code:

switch (true) {
// large box add padding
case(SHIPPING_MAX_WEIGHT <= $shipping_weight):
$shipping_weight = $shipping_weight + ($shipping_weight*($zc_large_percent/100)) + $zc_large_weight;
break;
default:
// add tare weight < large
$shipping_weight = $shipping_weight + ($shipping_weight*($zc_tare_percent/100)) + $zc_tare_weight;
break;
}

Replace with:


Code:

switch (true) {
// 1st Tare Rule
case($shipping_weight <= 1.75):
$shipping_weight = $shipping_weight + 0.375;
break;
// All Other Tare Weight
default:
$shipping_weight = $shipping_weight + 0.57;
break;
}

A nice thing about the original code is that it uses the switch statement. If needed you can add more tare weights and rules by copying the first one. Adding more "case" sections can allow for many more rules to be set up.



Cheers.









Thanks for the update that you were able to solve this and for posting the changes that worked for you in order to help others ...






Reply Or Comment!
Please LogIn to Reply!