Page 1 of 3 123 LastLast
Results 1 to 10 of 22
  1. #1
    Join Date
    Sep 2006
    Location
    Colorado Springs CO USA
    Posts
    516
    Plugin Contributions
    2

    Default Setting max weight for USPS

    I need to restrict shipments via the USPS shipping module to less than 8 ounces per package.

    The reason for this request has to do with some restricted (hazardous) items I ship. The postal service will only accept one bottle (flammable liquid container) per package. Since this product is only available in four ounce bottles that means I can only ship one four ounce bottle per package. The only USPS service option I will be using for my store is Parcel Post. All other products I sell in this store exceed the volume limits of/and are prohibited in the postal service.

    Simply stated:
    Maximum weight per package, USPS, is 8 ounces (this will be the product weight plus tare weight).
    No effect on other shipping modules (UPS, FEDEX)

    There are a couple of approaches I have considered:

    1. Add functionality to /includes/modules/shipping/usps.php that would compute how many packages would be needed to ship x number of bottles and then multiply the quote by that number (similar to admin-> configuration-> Shipping/Packaging-> "Enter the Maximum Package Weight you will ship". This coding is likely to be extensive and the benefit of such resolution may not warrant that amount of work. For orders of 2 or more bottles, UPS pricing is more competitive. Having said that, this approach would take care of multi bottle orders to Hawaii, Puerto Rico and Alaska where USPS is the only option. (UPS Ground Service flies to these areas and air transport of these products is prohibited.)
    2. A simpler method would be to simply place a limit on the maximum weight (8 ounces) to be shipped via the usps module. If a person orders more than 1 bottle, the weight will exceed this limit and the USPS quote will not be displayed, however UPS will still be displayed.
    Currently I offer only UPS ground service for all products. Providing for USPS Parcel service for single bottle orders will lower the shipping costs for these customers.

    I'm hoping someone can help me figure where to place the code within the usps.php file. This file configures admin, posts configurations in the mysql database, obtains quotes from usps and probably a number of other functions. I can come up with an if..else statement for approach #2 above, but I get lost within the usps.php file and can't figure where to place it.

    Any help would be appreciated.

  2. #2
    Join Date
    Jul 2005
    Posts
    84
    Plugin Contributions
    0

    Default Re: Setting max weight for USPS

    We are in the same boat as well, any help would be greatly appreciated!

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

    Default Re: Setting max weight for USPS

    You can edit the module at the function quote in the code something similar to:
    Code:
      function quote($method = '') {
        // BOF: UPS USPS
        global $order, $shipping_weight, $shipping_num_boxes, $transittime;
    
    if ($shipping_weight <= 10) {
      echo 'I SEE just right ' . $shipping_weight;
    } else {
      echo 'I SEE too much ' . $shipping_weight;
      return false;
    }
    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!]
    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!

  4. #4
    Join Date
    Sep 2006
    Location
    Colorado Springs CO USA
    Posts
    516
    Plugin Contributions
    2

    Default Re: Setting max weight for USPS

    Quote Originally Posted by Ajeh View Post
    You can edit the module at the function quote in the code something similar to:
    Code:
      function quote($method = '') {
        // BOF: UPS USPS
        global $order, $shipping_weight, $shipping_num_boxes, $transittime;
     
    if ($shipping_weight <= 10) {
      echo 'I SEE just right ' . $shipping_weight;
    } else {
      echo 'I SEE too much ' . $shipping_weight;
      return false;
    }

    Thanks Linda. I tried something similar but it didn't work. We need to disable the usps module earlier in the code. I have a solution and will post it here shortly.

    Ron

  5. #5
    Join Date
    Sep 2006
    Location
    Colorado Springs CO USA
    Posts
    516
    Plugin Contributions
    2

    Default Re: Setting max weight for USPS

    RESOLVED
    Goal:
    To set a maximum shipping weight limit beyond which the usps module is disabled.
    Problem:
    Special situation where USPS regulations limit how much flammable liquid may be shipped in a package. Specifically, USPS limit is 16 ounces. Furthermore, only one container may be shipped in a package.
    We sell 4 oz and 32 oz bottles of a flammable liquid. Obviously, 32 ounces cannot be shipped via USPS. In our case we can only use USPS to ship one 4 ounce bottle per package via Parcel Post. We used the weight of one bottle to determine when the customer has ordered more than one bottle.
    To limit a USPS shipment to only one 4 oz bottle, we need to weigh the bottle (a bit over 4 ounces when you include the container). In our case it came to 0.26 lbs. Since two bottles would be 0.52 lbs we set the limit in between these two numbers.
    Comments:
    This solution has very limited application. If you have a variety of products with differing shipping limitations this solution may not be flexible enough to handle all cases. We only had one product that could go USPS and that product was limited to one bottle per package. Everything else we sell on this site must go UPS or FEDEX ground because they exceed the 16 ounce USPS limit and they are all flammable liquids.
    Code changes:
    /includes/modules/shipping/usps.php:
    around line 58 find:
    Code:
      function usps() {
        global $order, $db, $template;
        $this->code = 'usps';
    change to:
    Code:
      function usps() {
        global $order, $db, $template, $shipping_weight; 
        $this->code = 'usps';
    around line 69 find:

    Code:
     
    // disable only when entire cart is free shipping
        if (zen_get_shipping_enabled($this->code)) {
          $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
        }
        if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_USPS_ZONE > 0) ) {
          $check_flag = false;
    change to:
    Code:
     
    // disable only when entire cart is free shipping or shipping weight exceeds store set limit
    if (zen_get_shipping_enabled($this->code)) {
    $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
    }
    if ($shipping_weight >0.3){
    $this->enabled = false;
    }
    if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_USPS_ZONE > 0) ) {
    $check_flag = false;
    If you wish to explain the limitation to your customers during checkout this can be done here:
    /includes/languages/english/php; or
    /includes/languages/[yourtemplatename]/english.php:
    around line 545 find:
    Code:
     
    define('CART_SHIPPING_OPTIONS', 'Estimate Shipping Costs');
    change to:

    Code:
     define('CART_SHIPPING_OPTIONS', 'Estimate Shipping Costs - [add your text here]');
    Example:
    define('CART_SHIPPING_OPTIONS', 'Estimate Shipping Costs <div> <font size="1">ALASKA, HAWAII, PUERTO RICO ONLY PLEASE NOTE: Your only option is Parcel Post. USPS regulations limit shipments to one 4 ounce bottle per package. Create a separate order for each additional 4 ounce bottle. Other states are offered UPS Ground service for larger orders.</font><br /><br /></div>');
    Ron

  6. #6
    Join Date
    Sep 2006
    Location
    Colorado Springs CO USA
    Posts
    516
    Plugin Contributions
    2

    Default Re: Setting max weight for USPS

    Well, looks like this is only partly resolved.

    This mod sets $this->enabled to false within function usps in /includes/modules/shipping/usps.php if the shipping weight exceeds the maximum hard coded within the mod.

    The Shipping Estimator reacts accordingly, however the mod seems to have no effect on shipping options listed on the Shipping Checkout page. The checkout page continues to display usps rates for items that exceed the shipping weight limit set by this mod.

    I expected that usps rates would not show up anywhere when the shipping weight exceeded the max set. Looks like a little more work is needed to accomplish the goal. Can anyone point me in the right direction?

    The goal, again, is to enable the USPS shipping module only when the shipping weight falls within certain limits set by the store owner.

    Ron

    Quote Originally Posted by ronlee67 View Post
    RESOLVED
    Goal:
    To set a maximum shipping weight limit beyond which the usps module is disabled.
    Problem:
    Special situation where USPS regulations limit how much flammable liquid may be shipped in a package. Specifically, USPS limit is 16 ounces. Furthermore, only one container may be shipped in a package.
    We sell 4 oz and 32 oz bottles of a flammable liquid. Obviously, 32 ounces cannot be shipped via USPS. In our case we can only use USPS to ship one 4 ounce bottle per package via Parcel Post. We used the weight of one bottle to determine when the customer has ordered more than one bottle.
    To limit a USPS shipment to only one 4 oz bottle, we need to weigh the bottle (a bit over 4 ounces when you include the container). In our case it came to 0.26 lbs. Since two bottles would be 0.52 lbs we set the limit in between these two numbers.
    Comments:
    This solution has very limited application. If you have a variety of products with differing shipping limitations this solution may not be flexible enough to handle all cases. We only had one product that could go USPS and that product was limited to one bottle per package. Everything else we sell on this site must go UPS or FEDEX ground because they exceed the 16 ounce USPS limit and they are all flammable liquids.
    Code changes:
    /includes/modules/shipping/usps.php:
    around line 58 find:
    Code:
      function usps() {
        global $order, $db, $template;
        $this->code = 'usps';
    change to:
    Code:
      function usps() {
        global $order, $db, $template, $shipping_weight; 
        $this->code = 'usps';
    around line 69 find:

    Code:
     
    // disable only when entire cart is free shipping
        if (zen_get_shipping_enabled($this->code)) {
          $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
        }
        if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_USPS_ZONE > 0) ) {
          $check_flag = false;
    change to:
    Code:
     
    // disable only when entire cart is free shipping or shipping weight exceeds store set limit
    if (zen_get_shipping_enabled($this->code)) {
    $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
    }
    if ($shipping_weight >0.3){
    $this->enabled = false;
    }
    if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_USPS_ZONE > 0) ) {
    $check_flag = false;
    If you wish to explain the limitation to your customers during checkout this can be done here:
    /includes/languages/english/php; or
    /includes/languages/[yourtemplatename]/english.php:
    around line 545 find:
    Code:
     
    define('CART_SHIPPING_OPTIONS', 'Estimate Shipping Costs');
    change to:

    Code:
     define('CART_SHIPPING_OPTIONS', 'Estimate Shipping Costs - [add your text here]');
    Example:
    define('CART_SHIPPING_OPTIONS', 'Estimate Shipping Costs <div> <font size="1"> These are flammable liquids. Postal regulations limit shipments to one 4 ounce bottle per package. (AK, HA, PR: Create a separate order for each additional 4 ounce bottle.) Shipments to states other than AK, HA, PR have the option to use UPS Ground service for orders of any quantity. </font><br /><br /></div>');
    Ron

  7. #7
    Join Date
    Sep 2006
    Location
    Colorado Springs CO USA
    Posts
    516
    Plugin Contributions
    2

    Default Re: Setting max weight for USPS

    My apologies to Linda (Ajeh). She provided the total solution in some very simple, concise code and I failed to recognize it.

    See her solution in post #3.

    To implement in /includes/modules/shipping/usps.php find around line 128:

    Code:
     
      function quote($method = '') {
        // BOF: UPS USPS
        global $order, $shipping_weight, $shipping_num_boxes, $transittime;
        if ( zen_not_null($method) && (isset($this->types[$method]) || in_array($method, $this->intl_types)) ) {
          $this->_setService($method);
        }
    change to:
    Code:
     
      function quote($method = '') {
        // BOF: UPS USPS
        global $order, $shipping_weight, $shipping_num_boxes, $transittime;
     
    if ($shipping_weight <= 10) {
     } else {
     return false;
    }
        if ( zen_not_null($method) && (isset($this->types[$method]) || in_array($method, $this->intl_types)) ) {
          $this->_setService($method);
    Change the "10" to whatever your max postal weight will b

    Thanks to Ajeh for this solution.

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

    Default Re: Setting max weight for USPS

    You are most welcome ... glad that solution worked for 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!]
    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!

  9. #9
    Join Date
    Nov 2008
    Posts
    19
    Plugin Contributions
    0

    Default Re: Setting max weight for USPS

    Quote Originally Posted by ronlee67 View Post
    My apologies to Linda (Ajeh). She provided the total solution in some very simple, concise code and I failed to recognize it.

    See her solution in post #3.

    To implement in /includes/modules/shipping/usps.php find around line 128:

    Code:
     
      function quote($method = '') {
        // BOF: UPS USPS
        global $order, $shipping_weight, $shipping_num_boxes, $transittime;
        if ( zen_not_null($method) && (isset($this->types[$method]) || in_array($method, $this->intl_types)) ) {
          $this->_setService($method);
        }
    change to:
    Code:
     
      function quote($method = '') {
        // BOF: UPS USPS
        global $order, $shipping_weight, $shipping_num_boxes, $transittime;
     
    if ($shipping_weight <= 10) {
     } else {
     return false;
    }
        if ( zen_not_null($method) && (isset($this->types[$method]) || in_array($method, $this->intl_types)) ) {
          $this->_setService($method);
    Change the "10" to whatever your max postal weight will b

    Thanks to Ajeh for this solution.
    You guys are so Awesome
    I have no knowledge about PHP at all, but I have so much done to my cart by just learning from you guys.
    I have paid Heritage Web Sol...(Beware) for a custom shopping cart and I was told they were going to "design a custom cart" (that's what they call it until they take you credit card number), making a long story short, after more than 2 months waiting and more than $1,500.00 charged on my card I found out they sold me a free Zen Cart with a colour changed template. (I just googled the company reputation after I felt robbed, and the results for the search were nasty)
    Now if I ask them to do this USPS code changed for me it would cost me a lots of $$. By the way they told me to use Authorize.net as gateway because after days working on installed Cybersource module they were not able to make it work, but I did thanks to you guys at this forum!!!

    BTW do you thing I can apply this code to USPS flat rate as well?

    Thank you guys again
    Last edited by riosouza; 19 Feb 2009 at 08:11 PM.

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

    Default Re: Setting max weight for USPS

    Glad that this was able to help you on customizing the shipping module ...

    However, you lost me a bit on what you mean by USPS Flat Rate ...

    If you mean one of the other shipping modules, then yes, the code is similar in all of the shipping modules ... if you change the value of the $this->enabled based on some condition then it will change when it shows or does not show in the checkout ...
    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!]
    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!

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. v150 USPS Max Shipping Weight + Exclude International
    By Kenichi in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 13 Jan 2013, 12:26 AM
  2. v139h Max weight restriction code for USPS Priority Mail Int Lrg Video box shipping option
    By heteromorphic in forum Addon Shipping Modules
    Replies: 9
    Last Post: 8 Sep 2012, 01:05 AM
  3. USPS max weight limit
    By buildingblocks in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 15 Sep 2011, 05:01 PM
  4. max weight for usps?
    By ryanb4614 in forum Addon Shipping Modules
    Replies: 11
    Last Post: 7 Nov 2008, 06:45 PM
  5. Setting a Max Price for a Payment Option
    By baraka in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 2 Feb 2007, 03:06 PM

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