Results 1 to 8 of 8
  1. #1

    Idea or Suggestion turn on/off the shippment base on product weight? Need PHP Help

    Hi All, some my products are heavy, the othes is light
    i have the pre item and mzmt shipping modules
    when the product's weight above 70lbs i want only show the pre item shipping module in checkout_shipping page, when the product's weight bellow 70lbs i want only show mzmt moduls.
    in the mzmt.php i have add the following code ,but is can not work.
    if ($products_weight = $product['products_weight'] < 70) {
    $this->enabled = ((MODULE_SHIPPING_MZMT_STATUS == 'False') ? true : false);
    } else {
    $this->enabled = ture;
    }

    or

    if ($order->info['products_weight'] < 70) {
    $this->enabled = ((MODULE_SHIPPING_MZMT_STATUS == 'False') ? true : false);
    } else
    $this->enabled =false;

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

    Default Re: turn on/off the shippment base on product weight? Need PHP Help

    You could use:
    PHP Code:
          // disable only when entire cart is free shipping
          
    if (zen_get_shipping_enabled($this->code)) {
            
    // not for over 70
            
    if (IS_ADMIN_FLAG || $shipping_weight 70) {
              
    $this->enabled = ((MODULE_SHIPPING_ITEM_STATUS == 'True') ? true false);
            }
          } 
    Don't forget to global $shipping_weight so that it is available to you ...
    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
    May 2005
    Location
    Toronto, Ontario, Canada
    Posts
    42
    Plugin Contributions
    0

    Default Re: turn on/off the shippment base on product weight? Need PHP Help

    I'm trying to turn on/off the shipment module based on price - the code below worked in ZC 1.37 just fine (by hiding the module). In this example, the module should not appear if the order is over $100.

    Code:
    global $order;
    
    if ($order->info['subtotal'] > 100)
      $this->enabled = false;
    Unfortunately, in ZC 1.38, it doesn't work anymore. Is there another command (not $this->enabled = false) that can be used to disable or hide the shipping module? Or perhaps the command works, but only once per session, so it can't be enabled or disabled "on the fly" in ZC 1.38?

    Any ideas?
    Dan G.

    Notebook Solutions Inc.

    http://www.notebooksolutions.ca

    Whoever said that money can’t buy happiness simply didn’t know where to go shopping.
    - Sydney J. Harris

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

    Default Re: turn on/off the shippment base on product weight? Need PHP Help

    Can you use:
    $order->info['total']

    the subtotal is 0 at that point so you are not obtaining a value ...
    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
    May 2005
    Location
    Toronto, Ontario, Canada
    Posts
    42
    Plugin Contributions
    0

    Default Re: turn on/off the shippment base on product weight? Need PHP Help

    Both $order->info['total'] and $order->info['subtotal'] have values and can be used in the "if" statement, the problem is that
    $this->enabled = false;
    command is ignored by the shipping module.
    Dan G.

    Notebook Solutions Inc.

    http://www.notebooksolutions.ca

    Whoever said that money can’t buy happiness simply didn’t know where to go shopping.
    - Sydney J. Harris

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

    Default Re: turn on/off the shippment base on product weight? Need PHP Help

    echo both values just above where you have the IF ...
    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!

  7. #7
    Join Date
    May 2005
    Location
    Toronto, Ontario, Canada
    Posts
    42
    Plugin Contributions
    0

    Default Re: turn on/off the shippment base on product weight? Need PHP Help

    Well, in my case, echo of "Subtotal" outputs the price of the product(s), while "Total" outputs the sum of products, taxes and other surcharges (if any) - so this is OK, you can use either value depending on your needs.

    I found out what the problem was: I was putting the custom "if" statement BEFORE the "zen_get_shipping_enabled" code, so the "if" statement (when true) would disable the module, but "zen_get_shipping_enabled" would just re-enable it - that's why it wasn't working.

    WRONG code:
    Code:
    global $order;
    
    if ($order->info['subtotal'] > 100)
      $this->enabled = false;
    
    // disable only when entire cart is free shipping
    if (zen_get_shipping_enabled($this->code))
      $this->enabled = ((MODULE_SHIPPING_ZONES_STATUS == 'True') ? true : false);
    Perhaps I was mislead by "// disable only when..." so I didn't realize that the 2 lines of code below it actually ENABLE the shipping module. Once I put the custom "if" statement AFTER "zen_get_shipping_enabled", it started working just fine.

    Working code:
    Code:
    // disable only when entire cart is free shipping
    if (zen_get_shipping_enabled($this->code))
      $this->enabled = ((MODULE_SHIPPING_ZONES_STATUS == 'True') ? true : false);
    
    global $order;
    
    if ($order->info['subtotal'] > 100)
      $this->enabled = false;
    Thanks for your help! The issue is now resolved.
    Dan G.

    Notebook Solutions Inc.

    http://www.notebooksolutions.ca

    Whoever said that money can’t buy happiness simply didn’t know where to go shopping.
    - Sydney J. Harris

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

    Default Re: turn on/off the shippment base on product weight? Need PHP Help

    Be aware that this will only work when the customer is logged in and that the Shipping Estimator will not work as there isn't an Order to build from until the customer logs in ...
    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. [not a bug] Turn Off Image Product Weight
    By articleck in forum Bug Reports
    Replies: 3
    Last Post: 18 Nov 2011, 02:09 AM
  2. Turn off display product weight broken
    By JLA in forum Upgrading from 1.3.x to 1.3.9
    Replies: 5
    Last Post: 13 May 2010, 07:55 PM
  3. How do I turn off the Item Weight listings?
    By MagicMan in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 18 Dec 2007, 01:38 PM
  4. Turn off product weight in shopping cart page
    By dealbyethan.com in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 12 Oct 2007, 12:30 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