Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / USPS First Class Mail Weight Range Change

USPS First Class Mail Weight Range Change

Locked

Views: 3,797

Results 1 to 12 of 12
This thread is locked. New replies are disabled.
25 Jan 2008, 10:42 PM
#1
tfgz avatar

tfgz

New Zenner

Join Date:
Aug 2006
Posts:
33
Plugin Contributions:
0

USPS First Class Mail Weight Range Change

I would like to offer USPS First Class mail, but restrict the weight to orders of less than 10 oz or .6249lbs. Essentially preventing it from being offered as an option for orders with weights of 10-13 oz. I would like to achieve this without having to add a tare, or changing product weights. Is there a way to edit the USPS scripts to do this? Any help with this would be greatly appreciated.

Using Zen 1.3.8a clean.

30 Jan 2008, 12:41 AM
#2
tfgz avatar

tfgz

New Zenner

Join Date:
Aug 2006
Posts:
33
Plugin Contributions:
0

Re: USPS First Class Mail Weight Range Change

If this cannot be accomplished by modifying the USPS shipping module, could another module such as 'Flat Rate' or 'Free Shipping' be retooled to offer a flat charge for orders under a certain weight?

I could be missing something, but looking at the existing modules there doesn't seem to be an option to allow this.

30 Jan 2008, 1:51 AM
#3
ajeh avatar

ajeh

Oba-san

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

Re: USPS First Class Mail Weight Range Change

You should be able to customize the usps.php shipping module by checking the $type against the current quote and skip First Class when the shipping weight is >= .6249 ...

Seems to work in testing ... :smile:

30 Jan 2008, 2:05 AM
#4
tfgz avatar

tfgz

New Zenner

Join Date:
Aug 2006
Posts:
33
Plugin Contributions:
0

Re: USPS First Class Mail Weight Range Change

Hey Ajeh, thanks for the quick reply, and cheers for the Alpha sorter the customers love it.

Any chance you can share the code you used for the test? I'm not quite savvy enough to generate my own. :cool:

30 Jan 2008, 2:08 AM
#5
ajeh avatar

ajeh

Oba-san

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

Re: USPS First Class Mail Weight Range Change

It wouldn't be any fun if I didn't make you beg for it first ... :eek:

Try editing the file:
/includes/modules/shipping/usps.php

and change the lines:

          $methods[] = array('id' => $type,
                             'title' => $title,
                             'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);

to read:

          if ($type == 'FIRST CLASS' && $shipping_weight >= .6249) {
            // skip First Class on >= .6249
          } else {
          $methods[] = array('id' => $type,
                             'title' => $title,
                             'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
          }

See if that doesn't block the First Class when you hit 10oz ...

NOTE: make sure you have addressed the Tare weight in the Shipping/Packaging before testing ...

30 Jan 2008, 2:34 AM
#6
tfgz avatar

tfgz

New Zenner

Join Date:
Aug 2006
Posts:
33
Plugin Contributions:
0

Re: USPS First Class Mail Weight Range Change

I must still not be begging enough because that code kills the estimator and shipping page. :wink: They both end up blank.

The tares are set to 0:0, but I'm assuming this was only to make sure I wasn't adding weight that could throw off the test.

30 Jan 2008, 2:42 AM
#7
ajeh avatar

ajeh

Oba-san

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

Re: USPS First Class Mail Weight Range Change

Make sure that you don't have any errors in the Admin ... Modules ... Shipping ...

If you do, there is a typo in the code or a blank space or line perhaps before the beginning <?php or after the ending ?> of the file ...

30 Jan 2008, 2:50 AM
#8
ajeh avatar

ajeh

Oba-san

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

Re: USPS First Class Mail Weight Range Change

And just in case this is how lines 188 to 210 read in case you miss placed a bracket etc.

        $methods = array();
        $size = sizeof($uspsQuote);
        for ($i=0; $i<$size; $i++) {
          list($type, $cost) = each($uspsQuote[$i]);

          // BOF: UPS USPS
          $title = ((isset($this->types[$type])) ? $this->types[$type] : $type);
          if(in_array('Display transit time', explode(', ', MODULE_SHIPPING_USPS_OPTIONS)))    $title .= $transittime[$type];
          /*
          $methods[] = array('id' => $type,
          'title' => ((isset($this->types[$type])) ? $this->types[$type] : $type),
          'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
          */
          if ($type == 'FIRST CLASS' && $shipping_weight >= .6249) {
            // skip First Class on >= .6249
          } else {
          $methods[] = array('id' => $type,
                             'title' => $title,
                             'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
          }
        }

        $this->quotes['methods'] = $methods;
30 Jan 2008, 3:00 AM
#9
tfgz avatar

tfgz

New Zenner

Join Date:
Aug 2006
Posts:
33
Plugin Contributions:
0

Re: USPS First Class Mail Weight Range Change

I was missing the last bracket. It seems to be working perfectly now. :clap: Thank you for your time and the help. I'll be sure to treat you and the staff to a cup of coffee!

30 Jan 2008, 3:06 AM
#10
ajeh avatar

ajeh

Oba-san

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

Re: USPS First Class Mail Weight Range Change

Kinda thought that might be it so I tossed in the extra large block of code so you wouldn't miss that one ... :cool:

Thanks for the coffee ... always a help to have support of the Zen Cart Software ... :smile:

21 Feb 2008, 10:32 PM
#11
ranger_lp avatar

ranger_lp

Zen Follower

Join Date:
Feb 2004
Location:
New York
Posts:
269
Plugin Contributions:
1

Re: USPS First Class Mail Weight Range Change

Tangential to this thread...can I set this up to not show First Class on orders below $75 for example?

16 Apr 2008, 6:01 PM
#12
helpme avatar

helpme

Totally Zenned

Join Date:
Apr 2007
Posts:
632
Plugin Contributions:
0

Re: USPS First Class Mail Weight Range Change

Is it possible to use USPS for under 30 lbs and table rate for over 30 lbs??

Thanks!