Beta 4 (and previous): Fix for USPS international shipping quotes

Posts: 5
Joined: 01/31/2008

If you're shipping a package internationally that has a weight denominated in ounces, you get an error when you try to pull up a USPS quote:

"Please enter a valid weight in ounces."

To fix this, replace line 494:
     '<Ounces>' . number_format($package->ounces, 1, '.', '') . '</Ounces>' . ?>

with
      '<Ounces>' . round($package->ounces) . '</Ounces>' .

Apparently ounces needs to be an integer.

Posts: 5
Joined: 01/31/2008

er, that's in uc_usps.module, of course.

Posts: 2267
Joined: 08/07/2007
AdministratoreLiTe!

Did they change it so you can't have decimal points in that field? Except for that, I don't see why using round() would fix it. Everything gets converted to strings anyway.

Posts: 931
Joined: 11/05/2007
Bug FinderFAQ ModeratorGetting busy with the Ubercode.

I checked the docs - for International rate requests only, ounces must be an integer. For Domestic, ounces is a float. That's why round is needed for International.

--

<tr>.

Posts: 2267
Joined: 08/07/2007
AdministratoreLiTe!

Ridiculous. Simply ridiculous.

Oh, and I'm going to use ceil(). If we round up, we make sure there's no short-changing anywhere. Though I can't imagine how a fraction of an ounce can make that much difference.

Posts: 69
Joined: 08/08/2007
Internationalizationizer

"fraction of an ounce can make that much difference."

flat rate envelopes have a hard 4lb limit, so a small amount can make a difference. . .

Posts: 2267
Joined: 08/07/2007
AdministratoreLiTe!

So if 4lb, 0.5oz is just as forbidden as 4lb, 1oz, I think it's ok. Something weighing 3lb, 15.5oz will be charged like 4lb, and it should still go through.

Posts: 69
Joined: 08/08/2007
Internationalizationizer

yep.
BTW,
this limit is just for international.

Posts: 15
Joined: 11/20/2007

much appreciated.

Posts: 91
Joined: 11/06/2007
Bug FinderGetting busy with the Ubercode.

Has this not been committed? I just downloaded Beta 6 and looked at the line in question and number_format is still being used for ounces.

Posts: 2267
Joined: 08/07/2007
AdministratoreLiTe!

Gee, looks like it wasn't. Must have gotten distracted by something. I've made the change for sure now, so it's taken care of.