Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Multiple Tare Weights

Multiple Tare Weights

Locked

Views: 1,082

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
19 Jul 2010, 11:04 PM
#1
patternman avatar

patternman

New Zenner

Join Date:
Jul 2008
Posts:
63
Plugin Contributions:
0

Multiple Tare Weights

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.

20 Jul 2010, 5:50 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Multiple Tare Weights

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 ...

21 Jul 2010, 11:32 PM
#3
patternman avatar

patternman

New Zenner

Join Date:
Jul 2008
Posts:
63
Plugin Contributions:
0

Re: Multiple Tare Weights

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:

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:

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. :smile:

22 Jul 2010, 1:53 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Multiple Tare Weights

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 ... :smile: