Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Limiting USPS shipping if over a certain weight.

Limiting USPS shipping if over a certain weight.

Views: 2,528

Results 1 to 20 of 23
23 Apr 2012, 4:24 PM
#1
merchantdroid avatar

merchantdroid

New Zenner

Join Date:
Oct 2010
Location:
Texas
Posts:
32
Plugin Contributions:
0

Limiting USPS shipping if over a certain weight.

I have searched this question with no luck, any direction would be much appreciated.

I would like to be able to control when USPS shipping is available by the order weight. Right now it displays no matter how heavy the order is... even with freight orders of 100 or more pounds. I would like to turn off USPS shipping option if over 50 pounds. Is that possible?

Also, is it possible to turn off "free shipping" if the item is a heavy freight item? I have the free shipping set for orders over a certain combined price (orders over $40 are free shipping... excluding freight orders). I tried setting two qualifying parameters for free shipping... $40 or more, but less than 100 lbs. However that does not work.

My needs are:

Offer Free Shipping on all orders $40 or more (excluding freight orders that are over 100lbs).
Offer USPS priority shipping on all orders under 50lbs.

Thanks in advance for any and all help.

24 Apr 2012, 6:25 PM
#2
micmed avatar

micmed

Zen Follower

Join Date:
Mar 2008
Location:
The Free South
Posts:
165
Plugin Contributions:
0

Re: Limiting USPS shipping if over a certain weight.

I really need this as well.

25 Apr 2012, 2:05 PM
#3
ajeh avatar

ajeh

Oba-san

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

Re: Limiting USPS shipping if over a certain weight.

It sounds like you are using the Free Shipping Options freeoptions ...

If so, you can customize the code in:
/includes/modules/shipping/freeoptions.php

with the code in Red:

// final check for display of Free Options
       if ($this->ck_freeoptions_total &&  $this->ck_freeoptions_weight or $this->ck_freeoptions_items) {
 
 
25 Apr 2012, 2:06 PM
#4
ajeh avatar

ajeh

Oba-san

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

Re: Limiting USPS shipping if over a certain weight.

merchantdroid:

Offer Free Shipping on all orders $40 or more (excluding freight orders that are over 100lbs).
Offer USPS priority shipping on all orders under 50lbs.

Are you saying limit only USPS priority ... or that happens to be the only only you offer?

26 Apr 2012, 5:26 PM
#5
merchantdroid avatar

merchantdroid

New Zenner

Join Date:
Oct 2010
Location:
Texas
Posts:
32
Plugin Contributions:
0

Re: Limiting USPS shipping if over a certain weight.

Thank you Ajeh for your help. I think I came up with a easier solution to my issues. The main issue I was having is that USPS and UPS were giving shipping options on everything.... no matter if they qualified for free shipping or if it was weights way over the two company's limits.

My difficulties were that I wanted to offer free shipping with a minimum order of $40 for all "non-freight" items. However I was not able to set all the parameters (with my limited knowledge) to limit shipping offers if they were not included with shipping discounts, etc.

What I ended up doing is turning off UPS and USPS shipping modules. I added the "Shipping by Quote" and turned on "table".

I decided to estimate a shipping charge per level of cart price and simply charge a set amount per level (table), this way I could manage my free shipping by cost as well as limit free shipping by cost (the freight that does not qualify for free shipping is well over $300)... so my table settings read:

9.99:6.99,19.99:7.99,29.99:8.99,39.99:10.99,299.99:0.00,4000.00:750.00

This translates to "if the cart order value is "X"/then the shipping charge is "Y"

0.01 - 9.99 = $6.99 shipping
10.00-19.99 = $7.99 shipping
20.00-29.99 = $8.99 shipping
30.00-39.99 = $10.99 shipping
40.00-299.99= $0.00 shipping
300.00-4000.00 = $750.00 shipping

I had to put in a dollar amount range to cut off the free shipping, so I estimated that I would not receive a single order over the cost of $300. If that starts to happen all I have to do is edit that parameter. I had to also put a shipping cost high enough to equal to a price over the actual freight costs that would occur so I would not be held accountable to honoring a automatic freight quote.

I added Freightquote.com so the clients could get an estimated freight cost in the shipping calculator... however I added the "Shipping by Quote" so the customer can either submit the order for a freight quote, or call us for the quote... then they can manually enter the quote and check out. I also added, "Orders over $300.00 and freight orders will require customers to use "Shipping by Quote" for the best discounts." in definitions.

This cleaned up my shipping page and put me in control of both my free shipping and my freight orders. As well, I don't have to show UPS and USPS. We have control to ship either way without the customer forcing us to use one or the other.

Hope this may help others trying to deal with this issue and not really advanced in coding.

26 Apr 2012, 8:42 PM
#6
ajeh avatar

ajeh

Oba-san

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

Re: Limiting USPS shipping if over a certain weight.

Thanks for the update and the details of how you handled this to suite your needs ...

18 May 2013, 3:54 PM
#7
merchantdroid avatar

merchantdroid

New Zenner

Join Date:
Oct 2010
Location:
Texas
Posts:
32
Plugin Contributions:
0

Re: Limiting USPS shipping if over a certain weight.

Okay, I know I have dug up one of my old threads... however I am still working on different shipping options with USPS. The above has been taken care of successfully. My new situation is that we offer very heavy items that I would only like to ship UPS. We use USPS a lot on smaller items. Is there a way to limit by weight the USPS shipping option? What I would like allow USPS shipping for orders less than 40 lbs. in weight, if 41 lbs. or more I would like for USPS not to be a shipping option.

Thanks for all the help!

18 May 2013, 4:05 PM
#8
ajeh avatar

ajeh

Oba-san

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

Re: Limiting USPS shipping if over a certain weight.

Depending on the USPS shipping module you will use, you can add the code in RED:

    // disable only when entire cart is free shipping
    if (zen_get_shipping_enabled($this->code)) {
      $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
    }
    
[B]// bof: disable over 40lbs    
        if (!IS_ADMIN_FLAG) {
            global $shipping_weight;
            if ($shipping_weight > 40) {
                $this->enabled = false;
            }
        }
// eof: disable over 40lbs    
[/B]

Or use ...

  function update_status() {
    global $order, $db;
    if (IS_ADMIN_FLAG == TRUE) return;

    // disable when entire cart is free shipping
    if (zen_get_shipping_enabled($this->code)) {
      $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
    }

    // disable only when entire cart is free shipping
    if (zen_get_shipping_enabled($this->code)) {
      $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
    }
    
[B]// bof: disable over 40lbs    
          global $shipping_weight;
          if ($shipping_weight > 40) {
              $this->enabled = false;
          }
// eof: disable over 40lbs    
[/B]
    if ($this->enabled == true) {
18 May 2013, 4:14 PM
#9
merchantdroid avatar

merchantdroid

New Zenner

Join Date:
Oct 2010
Location:
Texas
Posts:
32
Plugin Contributions:
0

Re: Limiting USPS shipping if over a certain weight.

Thanks Ajeh. I am using the actual USPS module with my USPS information. I dug up another thread that you assisted on in a similar fashion:

http://www.zen-cart.com/showthread.php?204706-USPS-Max-Shipping-Weight-Exclude-International&highlight=limit+usps+shipping+weight

Was almost ready to test it, however your coding is so much cleaner. :)

I will reply with my results. Thank you so very much!

18 May 2013, 4:31 PM
#10
ajeh avatar

ajeh

Oba-san

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

Re: Limiting USPS shipping if over a certain weight.

You are most welcome ... thanks for the update that this is now working for you ... :smile:

18 May 2013, 4:39 PM
#11
merchantdroid avatar

merchantdroid

New Zenner

Join Date:
Oct 2010
Location:
Texas
Posts:
32
Plugin Contributions:
0

Re: Limiting USPS shipping if over a certain weight.

Actually... when I added that code, it stopped the shipping estimator from working and when going to checkout, all there is ... is a blank page. I added this code to the usps.php file.... is that correct?

18 May 2013, 4:59 PM
#12
ajeh avatar

ajeh

Oba-san

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

Re: Limiting USPS shipping if over a certain weight.

Go to the Tools ... Developers Tool Kit ... and in the bottom input box enter:
usps.php

select Catalog ... and click SEARCH ...

what comes up?

18 May 2013, 5:10 PM
#13
merchantdroid avatar

merchantdroid

New Zenner

Join Date:
Oct 2010
Location:
Texas
Posts:
32
Plugin Contributions:
0

Re: Limiting USPS shipping if over a certain weight.

/home/****/public_html/includes/languages/english/modules/shipping/usps.php

Line #6 : * @version $Id: usps.php 4867 2006-10-31 09:59:01Z drbyte $

/home/****/public_html/includes/modules/shipping/usps.php

##################################################################################################################################__

Line #9 : * @version $Id: usps.php 15881 2010-04-11 16:32:39Z wilt $

Match Lines found: 2

I went back and uploaded the original usps.php file and we are back to normal. Can you tell me which file I should put the code you provided into? Maybe I simply overlooked the correct file. I think I may have accidentally added your suggested code to the languages ..... usps.php instead of the modules/shipping/usps.php file. That would have caused the system confusion. Rookie mistake, by not looking at the proper top file on my ftp.

18 May 2013, 5:24 PM
#14
ajeh avatar

ajeh

Oba-san

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

Re: Limiting USPS shipping if over a certain weight.

You need to first get the current version of USPS in the add on plugins ...

A search on:
usps

will bring up:
http://www.zen-cart.com/downloads.php?do=file&id=1292

18 May 2013, 5:33 PM
#15
merchantdroid avatar

merchantdroid

New Zenner

Join Date:
Oct 2010
Location:
Texas
Posts:
32
Plugin Contributions:
0

Re: Limiting USPS shipping if over a certain weight.

Okay, I will update. I added the code to your first suggestion and it did not turn off the USPS when the weight was over 40, so hopefully the update will fix it. I sure do appreciate your help!

18 May 2013, 6:02 PM
#16
merchantdroid avatar

merchantdroid

New Zenner

Join Date:
Oct 2010
Location:
Texas
Posts:
32
Plugin Contributions:
0

Re: Limiting USPS shipping if over a certain weight.

Sorry to be so bothersome, but when I installed the latest version of usps as you directed... the whole shipping modules in admin lost the right side for selecting and installing any of the modules. ????

18 May 2013, 6:08 PM
#17
ajeh avatar

ajeh

Oba-san

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

Re: Limiting USPS shipping if over a certain weight.

When that happens it is usually caused by 1 of 2 things ...

1 you have made a copy of the old usps.php in the directory:
/includes/modules/shipping

and that is breaking things as this is an auto loading directory ...

2 you have placed the files:
/includes/modules/shipping/usps.php (code file) in the language directory or ...
/includes/languages/english/modules/shipping/usps.php (language file) in the code directory

What version Zen Cart are you running?

What version of php are you running?

18 May 2013, 6:15 PM
#18
merchantdroid avatar

merchantdroid

New Zenner

Join Date:
Oct 2010
Location:
Texas
Posts:
32
Plugin Contributions:
0

Re: Limiting USPS shipping if over a certain weight.

PHP: 5.2.17
ZC: 1.3.9h

In the directory... I renamed the original usps.php files to usps_orig.php, just in case the new file would not work. After the first mess up, I double checked to make sure that the proper usps.php files were in the proper folders.

18 May 2013, 6:21 PM
#19
merchantdroid avatar

merchantdroid

New Zenner

Join Date:
Oct 2010
Location:
Texas
Posts:
32
Plugin Contributions:
0

Re: Limiting USPS shipping if over a certain weight.

I noticed the mention of CURL, can you tell me where to look to make sure that is correct?

18 May 2013, 6:31 PM
#20
ajeh avatar

ajeh

Oba-san

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

Re: Limiting USPS shipping if over a certain weight.

Change this from:
usps_orig.php

to be:
usps_orig_php

that is an auto loading directory and all files that end in .php will try to load and you are getting a conflict between the code in:
usps.php

and your old:
usps_orig.php