USPS rounding issues

Locked

Views: 3,598

Results 1 to 11 of 11
This thread is locked. New replies are disabled.
6 Jan 2010, 7:19 PM
#1
gothstone avatar

gothstone

Zen Follower

Join Date:
Jun 2005
Posts:
330
Plugin Contributions:
0

USPS rounding issues

I think the store owner explains this better than I can, so please see her email below. I am running the brand new USPS.php file, with this mornings minor change.

I have logged in as [email protected] with the password tests with a bogus United Kingdom address. This can actually be done without being logged in if you are simply viewing the estimate shipping on the shopping cart page, by selecting United Kingdom as the country. I can add items to the shopping cart up to 0.56 lb and both International First class and International priority mail options are shown in the shipping estimator (these are the only options we offer for shipping methods) and on the checkout page. At 0.58 oz, no options are shown and postage is zero, preventing a customer from completing checkout.

example used Small Head Incredible Hulk Pez early 1990s with an item weight of 0.07lb and a package tare of +10%,

I can add up to 8 of these to the shopping cart and still see both shipping options. The Cart weight shows as 0.56 lbs and I believe it is rounding this down to 0.5 lbs or 8 oz. The shipping weight shows as 0.62 lbs which would be 9.9 oz. When a 9th is added and the cart weight would go to 0.63lb with a ship weight of 0.70, the estimator breaks and shows no shipping methods.

I believe there is a two fold problem here. One part is the rounding downward of the weight increment and second is the breaking of the cart at over 8 ounces or half a pound.

The USPS calculates postage at a different rate in one ounce increments from 1 - 8 ounces, then in 4 oz increments up to 64 oz (4 lbs) for international first class mail packages. For International Priority mail, the weight increments are in 1 lb increments up to 70 lbs.

2 + 2 = 5 for extremely large values of 2

Pez Collectors Store •••••••• My Plugins List

7 Jan 2010, 3:06 AM
#2
ajeh avatar

ajeh

Oba-san

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

Re: USPS rounding issues

Check that you have added the new January 4, 2010 USPS updated usps.php file and that you have applied the change to it found for decimal issues on International USPS ...
http://www.zen-cart.com/forum/showthread.php?t=144992

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!

7 Jan 2010, 12:01 PM
#3
gothstone avatar

gothstone

Zen Follower

Join Date:
Jun 2005
Posts:
330
Plugin Contributions:
0

Re: USPS rounding issues

Yes, I have both.

2 + 2 = 5 for extremely large values of 2

Pez Collectors Store •••••••• My Plugins List

7 Jan 2010, 3:08 PM
#4
ajeh avatar

ajeh

Oba-san

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

Re: USPS rounding issues

Could you go to the Tools ... Developers Tool Kit ... and do a search on:
// usps currently

does that come up in the USPS shipping module
/includes/modules/shipping/usps.php

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!

7 Jan 2010, 3:13 PM
#5
gothstone avatar

gothstone

Zen Follower

Join Date:
Jun 2005
Posts:
330
Plugin Contributions:
0

Re: USPS rounding issues

Yup:
/home/removed/public_html/includes/modules/shipping/usps.php

Line #160 : // usps currently cannot handle more than 5 digits on international

2 + 2 = 5 for extremely large values of 2

Pez Collectors Store •••••••• My Plugins List

7 Jan 2010, 3:16 PM
#6
ajeh avatar

ajeh

Oba-san

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

Re: USPS rounding issues

I have Tare at 10:0 and weight at 0.07 and with a London UK EC1N-8JH I get:

United States Postal Service (1 x 0.63lbs) (Global Express Guaranteed Non-Document Rectangular (1 - 3 days)) $64.00
United States Postal Service (1 x 0.63lbs) (Global Express Guaranteed Non-Document Non-Rectangular (1 - 3 days)) $64.00
United States Postal Service (1 x 0.63lbs) (Express Mail International (5 days)) $33.50
United States Postal Service (1 x 0.63lbs) (Express Mail International Flat Rate Envelope (5 days)) $28.95
United States Postal Service (1 x 0.63lbs) (Priority Mail International (6 - 10 days)) $28.00
United States Postal Service (1 x 0.63lbs) (Priority Mail International Large Flat Rate Box (6 - 10 days)) $55.95
United States Postal Service (1 x 0.63lbs) (Priority Mail International Medium Flat Rate Box (6 - 10 days)) $43.45
United States Postal Service (1 x 0.63lbs) (Priority Mail International Small Flat Rate Box (6 - 10 days)) $13.45
United States Postal Service (1 x 0.63lbs) (Priority Mail International Flat Rate Envelope (6 - 10 days)) $13.45
United States Postal Service (1 x 0.63lbs) (First-Class Mail International Package (Varies)) $9.04
United States Postal Service (1 x 0.63lbs) (First-Class Mail International Large Envelope (Varies)) $8.84

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!

8 Jan 2010, 1:34 AM
#7
gothstone avatar

gothstone

Zen Follower

Join Date:
Jun 2005
Posts:
330
Plugin Contributions:
0

Re: USPS rounding issues

After much fiddling, and argument I realized that while the error message from USPS was saying that it could only handle 5 digits, in reality 3 were to much. Changing the zen_round to 2 mostly fixed the problem.

The second problem is that way USPS deals with ounces. As far as their charges go 5.00000001 ounces is still 6 ounces. On rare occasions we were having an error were the 5 ounce rate was quoted and charged instead of 6.

Since USPS doesn't deal in decimals the solution for all this is fairly simple, quit giving them decimals in the first place. Below is the code we are using to do so.

Ajeh - assuming you agree with the principal here, please go over the code as I doubt its the cleanest way to do this. Then I would suggest posting it to the announcement thread. It will only affect people with very small items (the one I've been testing with is 1.12 ounces) but it may drive those few insane as it did me.

    // usps doesnt accept zero weight send 1 ounce (0.0625) minimum
    $usps_shipping_weight = ($shipping_weight <= 0.0 ? 0.0625 : $shipping_weight);
    $shipping_pounds = floor ($usps_shipping_weight);
    $shipping_ounces = (16 * ($usps_shipping_weight - floor($usps_shipping_weight)));
    // usps currently does not think in decimals
    $shipping_ounces = ceil ($shipping_ounces);
    if ( $shipping_ounces == 16 ) {
	$shipping_pounds++;
	$shipping_ounces = 0;
	}

2 + 2 = 5 for extremely large values of 2

Pez Collectors Store •••••••• My Plugins List

8 Jan 2010, 1:37 AM
#8
ajeh avatar

ajeh

Oba-san

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

Re: USPS rounding issues

You might look at the 5 digit fix posted on the announcement for this International issue ...
http://www.zen-cart.com/forum/showthread.php?t=144992

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!

8 Jan 2010, 1:44 AM
#9
gothstone avatar

gothstone

Zen Follower

Join Date:
Jun 2005
Posts:
330
Plugin Contributions:
0

Re: USPS rounding issues

Yes, I had read and added that, as I said a couple of posts ago, and in my first post. Though I can't explain why $shipping_ounces = zen_round($shipping_ounces, 3); did not always work. $shipping_ounces = zen_round($shipping_ounces, 2); seemed to, though there might be some interesting situation where it wouldn't have. More importantly, this may still result in an incorrect quote from USPS. If you round 4lbs 5.0001 ounces that way zencart will tell the USPS the package weighs 4lbs 5 ounces . The post office however will charge for 4lbs 6 ounces. By converting to whole numbers before posting to USPS all issues are eliminated.

2 + 2 = 5 for extremely large values of 2

Pez Collectors Store •••••••• My Plugins List

8 Jan 2010, 7:30 PM
#10
traderdan avatar

traderdan

New Zenner

Join Date:
Jan 2008
Location:
Essex, MA
Posts:
41
Plugin Contributions:
0

Re: USPS rounding issues

This may be a stupid question but, I just want to be sure I understand what "You will need to do a REMOVE, INSTALL and Configure for the changes to take effect" really means...

are these instructions in reference to the USPS shipping module?

Thanks for all the work on this... the USPS shipping module was/is definitely in need of attention.

-Dan

8 Jan 2010, 8:04 PM
#11
ajeh avatar

ajeh

Oba-san

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

Re: USPS rounding issues

You need to get the new USPS shipping module for January 4, 2010 at:
http://www.zen-cart.com/forum/showthread.php?t=144992

and save your current settings, then do an REMOVE, INSTALL and reconfigure just like instructed ...

Note: there is also a change posted on it to update for the 5 digit issue on International shipping for ounces ...

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!