10 replies [Last post]
xylocopa's picture
Offline
Joined: 01/31/2008
Juice: 24
Was this information Helpful?

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.

xylocopa's picture
Offline
Joined: 01/31/2008
Juice: 24
Re: Beta 4 (and previous): Fix for USPS international shipping q

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

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Re: Beta 4 (and previous): Fix for USPS international shippi

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.

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3424
Re: Re: Re: Beta 4 (and previous): Fix for USPS international sh

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>.
Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Re: Re: Re: Beta 4 (and previous): Fix for USPS internationa

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.

dkashen's picture
Offline
Internationalizationizer
Joined: 08/08/2007
Juice: 180
"fraction of an ounce can

"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. . .

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: "fraction of an ounce can

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.

dkashen's picture
Offline
Internationalizationizer
Joined: 08/08/2007
Juice: 180
yep. BTW, this limit is just

yep.
BTW,
this limit is just for international.

Shiraz's picture
Offline
Joined: 11/20/2007
Juice: 32
thank you xylocopa

much appreciated.

greenSkin's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 11/06/2007
Juice: 263
Re: Beta 4 (and previous): Fix for USPS international shipping q

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.

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Re: Beta 4 (and previous): Fix for USPS international shippi

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.