Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2007
    Posts
    21
    Plugin Contributions
    0

    Default Restricting Shipping method by weight. Tare is not counted.

    Hi all,

    I hope this is the right forum to ask this question.

    A few months ago, I asked whether I could restrict the shipping method by weight. I was restricting by quantity, but weight turned to be much more convenient.

    Basically, I have two available shipping methods, but one of them only accepts packages up to 2kg. I have my weights in lbs. The code I'm using in zones.php is:

    Code:
          global $cart;
          if (!IS_ADMIN_FLAG && $_SESSION['cart']->weight >= 4.4) {
            $this->enabled = false;
          }
    So if anything weights more than 4.4lbs, this method won't appear.

    But recently, I got an order for products that combined weighted 4.75lbs, yet the restricted method showed, so I get an order that says "The shipping rate cannot be determined at this time" even though I restricted it to 4.4lbs tops.

    So I checked to see what happened, since the code is right.

    It turns out that the products actually weight 3.75lbs, which is under my 4.4lbs limit, and I set a tare weight of 1lb for any package, so when added, I get 4.75lbs.

    But the code checks for the product weight only, not the product + tare, so the code doesn't work. The invalid shipping method shows.

    I hope I've explained it right!

    Now for my question, what can I do so the code tests for the whole weight, including product + tare? Maybe something along the lines of:

    Code:
          global $cart;
          if (!IS_ADMIN_FLAG && $_SESSION['cart']->totalweight >= 4.4) {
            $this->enabled = false;
          }
    Is there any such variable?

    Thanks in advance for any pointers here,

    Humberto
    http://www.panamarts.com

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Restricting Shipping method by weight. Tare is not counted.

    The weight with Tare is not available until you get into the function quote by using a:
    global $shipping_weight;

    if that is not already in there ...

    $_SESSION['cart']->weight is the weight without the Tare and is available with the:
    global $cart;
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  3. #3
    Join Date
    Sep 2007
    Posts
    21
    Plugin Contributions
    0

    Default Re: Restricting Shipping method by weight. Tare is not counted.

    Hi Linda,

    Thanks for the prompt response. I'm not a programmer, so I'm not sure I get what you're telling me.

    Would this work?:

    Code:
          global $cart, $shipping_weight;
          if (!IS_ADMIN_FLAG && $_SESSION['cart']->shipping_weight >= 4.4) {
            $this->enabled = false;
          }
    Or would that be:

    Code:
          global $shipping_weight;
          if (!IS_ADMIN_FLAG && $_SESSION['shipping_weight']->weight >= 4.4) {
            $this->enabled = false;
          }
    TIA,

    Humberto

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Restricting Shipping method by weight. Tare is not counted.

    Neither will work in the top of the shipping module as the variable:
    $shipping_weight

    is not known yet ...

    At the top you can use the:
    Code:
          global $cart;
          if (!IS_ADMIN_FLAG && $_SESSION['cart']->shipping_weight >= 3.4) {
            $this->enabled = false;
          }
    if you know you are adding 1lb to the weight just lower the weight on your test ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  5. #5
    Join Date
    Sep 2007
    Posts
    21
    Plugin Contributions
    0

    Default Re: Restricting Shipping method by weight. Tare is not counted.

    OMG a "duh" Moment! LOL

    I'll do just that

    Cheers,

    Humberto

  6. #6
    Join Date
    Sep 2007
    Posts
    21
    Plugin Contributions
    0

    Default Re: Restricting Shipping method by weight. Tare is not counted.

    Oh, and thanks!

  7. #7
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Restricting Shipping method by weight. Tare is not counted.

    Sometimes it is the easy ideas that slip our minds ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

 

 

Similar Threads

  1. Tare Weight and Displayed Shipping Weight
    By lynbor in forum Basic Configuration
    Replies: 3
    Last Post: 15 Jul 2010, 01:16 AM
  2. Tare : monney, not weight .
    By Akasashasha in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 8 Jun 2009, 05:02 PM
  3. USPS shipping module / tare weight
    By buildingblocks in forum Built-in Shipping and Payment Modules
    Replies: 15
    Last Post: 29 Nov 2008, 06:18 PM
  4. Shipping tare weight/boxes configuration does not work for FedEx
    By fpbear in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 28 Jul 2008, 04:24 AM
  5. Shipping Weight calculated incorrectly - Not Tare Settings!
    By levbeck in forum Built-in Shipping and Payment Modules
    Replies: 20
    Last Post: 23 Sep 2007, 12:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR