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

    help question Disable shipping method by weight. zones.php

    Hi all,

    I've been searching but unable to find an answer for this:

    I use two shipping methods, one is Certified Mail and the other is EMS (I'm based in Panama). For both, I use zones.php. I use two copies, renamed one to ems.php. It works great.

    The issue I have is that Certified Mail (zones.php) only accepts up to 4.4lbs.

    If the order goes higher than that, I get a "The shipping rate cannot be determined at this time, $0.00" message, but the user can continue and place the order anyway.

    What I need is a way to restrict the shipping method, so that if the order weights more than 4.4lbs, the Certified Mail option doesn't appear.

    At first, I thought I had solved the by using a simple, not-elegant method, (since I'm not a programmer), and I tested for number of products:

    Code:
          if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_id','8') > 4)) { 
              $this->enabled = false; 
          }  
          if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_id','9') > 0)) { 
              $this->enabled = false; 
          }  
          if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_id','112') > 0)) { 
              $this->enabled = false; 
          } 
          if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_id','111') > 2)) { 
              $this->enabled = false; 
          } 
          if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_id','119') > 2)) { 
              $this->enabled = false; 
          } 
          if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_id','120') > 0)) { 
              $this->enabled = false; 
          }
    So when a customer orders more than a certain amount of products, the Certified Mail option doesn't even appear and the customer is forced to choose EMS.

    But today a customer placed an order that included some of these products and another not tested for, and got the same message.

    So what I really need is to test for weight, but I don't have the slightest idea of how to do that!

    I'm currently using v1.3.9h, my zones.php says:

    Code:
    /**
     * @package shippingMethod
     * @copyright Copyright 2003-2006 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: zones.php 6347 2007-05-20 19:46:59Z ajeh $
     */
    My site is at http://www.panamarts.com

    How would I do that?

    Thanks in advance for any help,

    Humberto Olarte Cupas

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

    Default Re: Disable shipping method by weight. zones.php

    First you need to add this to your stylesheet.css
    .hiddenField {
    display: none;
    }

    .visibleField {
    display: inline;
    }
    Next, where do you have your code in the zones.php file?

    If what you are really trying to control is not to see Zone Rate zones when the weight is over 4lbs ... you can customize it with:
    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);
          }
    
    // bof: do not show if weight > 4
          global $cart;
          if (!IS_ADMIN_FLAG && $_SESSION['cart']->weight > 4) {
            $this->enabled = false;
          }
    // eof: do not show if weight > 4
    
          // CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED
    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: Disable shipping method by weight. zones.php

    Thank you very much, Linda!

    This check almost does what I want. I just need to fine-tune the exact weight I want to test for.

    Currently the code I have in zones.php is:

    Code:
    /**
     * @package shippingMethod
     * @copyright Copyright 2003-2006 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: zones.php 6347 2007-05-20 19:46:59Z ajeh $
     */
    
    ...snip...
    
      class zones {
        var $code, $title, $description, $enabled, $num_zones;
    
    // class constructor
        function zones() {
          $this->code = 'zones';
          $this->title = MODULE_SHIPPING_ZONES_TEXT_TITLE;
          $this->description = MODULE_SHIPPING_ZONES_TEXT_DESCRIPTION;
          $this->sort_order = MODULE_SHIPPING_ZONES_SORT_ORDER;
          $this->icon = '';
          $this->tax_class = MODULE_SHIPPING_ZONES_TAX_CLASS;
          $this->tax_basis = MODULE_SHIPPING_ZONES_TAX_BASIS;
    
          // disable only when entire cart is free shipping
          if (zen_get_shipping_enabled($this->code)) {
            $this->enabled = ((MODULE_SHIPPING_ZONES_STATUS == 'True') ? true : false);
          }
          // disable for one master_categories_id 
          if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_id','8') > 4)) { 
              $this->enabled = false; 
          }  
          if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_id','9') > 0)) { 
              $this->enabled = false; 
          }  
          if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_id','112') > 0)) { 
              $this->enabled = false; 
          } 
          if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_id','111') > 2)) { 
              $this->enabled = false; 
          } 
          if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_id','119') > 2)) { 
              $this->enabled = false; 
          } 
          if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_id','120') > 0)) { 
              $this->enabled = false; 
          } 
    
    
          // CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED
          $this->num_zones = 5;
        }
    
    // class methods
        function quote($method = '') {
          global $order, $shipping_weight, $shipping_num_boxes, $total_count;
          $dest_country = $order->delivery['country']['iso_code_2'];
          $dest_zone = 0;
          $error = false;
    
    ... snip ...
    I'll now take those checks out and just test for weight.

    Thanks again,

    Humberto

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

    Default Re: Disable shipping method by weight. zones.php

    Hi again, Linda,

    This post is just to thank you again. I ended using the code like this:

    Code:
    // bof: do not show if weight >= 4.4
          global $cart;
          if (!IS_ADMIN_FLAG && $_SESSION['cart']->weight >= 4.4) {
            $this->enabled = false;
          }
    // eof: do not show if weight >= 4.4
    Works like a charm.

    But while using it, I discovered what might be a bug. I'm not sure.

    As you can see here:

    http://panamarts.com/store/index.php...=index&cPath=4

    I've set up max quantities for these products. This is also due to shipping limitations.

    What I found is that if I enter the products detailed info, and use the max amount in the "Add to cart" text box, I have no problems.

    But let's take for example this product, which has a Max Qty of 11.

    If enter 11 in the textbox and press Add to cart, I can checkout with no problems.

    But if I enter, say, 1 and then I try to correct it and enter 11, I get an error saying that I went over the max amount and limits me to 10.

    Anyway, the weight solution works like as advertised.

    Cheers,

    Humberto

 

 

Similar Threads

  1. Multiple Shipping Zones Rate Module - Shipping Method Choosing
    By ahmose in forum Addon Shipping Modules
    Replies: 19
    Last Post: 17 Aug 2015, 02:17 PM
  2. v151 Disable a payment method for a chosen shipping method?
    By chowyungunz in forum Built-in Shipping and Payment Modules
    Replies: 7
    Last Post: 12 Jun 2015, 12:56 PM
  3. Disable Table shipping method with weight?
    By joecooper in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 1 Aug 2012, 05:53 PM
  4. Change zones shipping calculation method from Weight to Product Model
    By kloving in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 3 Feb 2010, 10:06 AM
  5. disable shipping method
    By bhadz08 in forum Managing Customers and Orders
    Replies: 2
    Last Post: 20 Jul 2009, 06:14 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