Page 1 of 3 123 LastLast
Results 1 to 10 of 21
  1. #1
    Join Date
    Jan 2008
    Location
    Essex, MA
    Posts
    41
    Plugin Contributions
    0

    red flag USPS Rounding Errors -- Should never round down

    Cart Version: 1.3.8a

    OK before anybody asks, please note that all my tare settings are off (0:0) and therefore the weights of my products alone determine the shipping calculation. I also include a $1.00 handling fee with each order.

    That said, there are clear rounding errors with USPS shipping module. If you use this T-shirt as an example and add a size Large to the shopping cart, you'll see that it weighs a total of 0.482lbs. When converted to ounces, this is 7.712 which USPS requires be rounded up to 8.0. The USPS shipping module, in this example, rounds correctly and the total shipping charge for 1st Class Mail is $3.41.

    NOW, remove that item from the cart and re-add the same T-shirt in a size Medium. This product weighs a total of 0.452lbs, or 7.264 ounces when converted. Problem here is that the shipping module only wants to charge $3.24 for shipping, which means it is only considering it to be a 7-ounce item... THIS IS WRONG.

    The module should always be rounding up to the nearest whole ounce since this is how the USPS operates. Can someone please tell me where in the code I can update this rounding routine?


    Thanks in advance,
    -Dan

  2. #2
    Join Date
    Jan 2008
    Location
    Essex, MA
    Posts
    41
    Plugin Contributions
    0

    Default Re: USPS Rounding Errors -- Should never round down

    Anybody...?

  3. #3
    Join Date
    Jan 2008
    Location
    Essex, MA
    Posts
    41
    Plugin Contributions
    0

    Default Re: USPS Rounding Errors -- Should never round down

    So no admins actually care that the USPS Shipping Module simply does NOT function correctly? Say it ain't so.....

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    67,213
    Plugin Contributions
    6

    Default Re: USPS Rounding Errors -- Should never round down

    Google says ...
    0.482 pounds = 7.71200 ounces

    0.452 pounds = 7.23200 ounces

    Could you also post your Ship From and Ship To so we are comparing apples and apples?
    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: v1.5.3]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

  5. #5
    Join Date
    Jan 2008
    Location
    Essex, MA
    Posts
    41
    Plugin Contributions
    0

    Default Re: USPS Rounding Errors -- Should never round down

    Ajeh, you're right about what Google says, 0.452 lbs is 7.232 ounces... a typo in my post, but it doesn't actually change anything. It's over 7 ounces, therefore USPS will automatically charge you at the 8-ounce rate, which for 1st Class Mail would be $2.41. And it's still apples to apples since USPS First Class Mail isn't determines by zip code.

    So you see, it shouldn't matter whether my package weighs 7.712 or 7.232 ounces, either way ZC should calculate the shipping charge based on 8-ounces. Unfortunately, this doesn't appear to be what's happening.

    Instead, it assigns the correct $2.41 charge to the package weighing 7.781, which I assume is because, simply enough, the routine correctly rounded up to 8.000. But then ZC only assigns a $2.24 charge (the USPS 7-ounce rate) to the package weighing 7.232, even though the USPS requires that I ship it at the 8-ounce rate. Here I suspect it's just a matter of the Shipping Module rounding down from 7.232 when in fact it should still round up to 8.000 as well.

    If it were up to me and I knew where exactly I could tweak the code, I'd make it so the module would round up for anything that's, say, 0.050 over the full-ounce mark.


    Did that all make sense?
    Last edited by TraderDan; 11 Jul 2009 at 05:54 AM.

  6. #6
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    67,213
    Plugin Contributions
    6

    Default Re: USPS Rounding Errors -- Should never round down

    Look in the usps.php shipping module and tweak the calculation on the pounds and ounces to the way you want it to work ...

    We will look further into this for a future release ...
    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: v1.5.3]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

  7. #7
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    67,213
    Plugin Contributions
    6

    Default Re: USPS Rounding Errors -- Should never round down

    Edit your usps.php shipping module and change:
    Code:
        $shipping_ounces = round(16 * ($usps_shipping_weight - floor($usps_shipping_weight)));
    to read:
    Code:
        $shipping_ounces = (16 * ($usps_shipping_weight - floor($usps_shipping_weight)));
    Do you get more accurate rates now?
    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: v1.5.3]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

  8. #8
    Join Date
    Jan 2008
    Location
    Essex, MA
    Posts
    41
    Plugin Contributions
    0

    Default Re: USPS Rounding Errors -- Should never round down

    Ajeh-

    Thanks for taking the time to help. It's been a while since my initial posting (cra-zee busy these days), but I have just implemented the suggested change and will let you know.

    And since we're on the topic of the USPS shipping module, I have another related question... why is ZC insisting that a 1-ounce package shipped to Canada cost $20 USPS Priority International?!

    I have both First-Class Mail International and Priority Mail International enabled in my module, but even for a 1-ounce package it is coming up with a $20 Priority charge ONLY. Any insight would be greatly appreciated... again.

    Thanks in advance,
    -Dan

  9. #9
    Join Date
    Jan 2008
    Location
    Essex, MA
    Posts
    41
    Plugin Contributions
    0

    Default Re: USPS Rounding Errors -- Should never round down

    Quote Originally Posted by Ajeh View Post
    Edit your usps.php shipping module and change:
    Code:
        $shipping_ounces = round(16 * ($usps_shipping_weight - floor($usps_shipping_weight)));
    to read:
    Code:
        $shipping_ounces = (16 * ($usps_shipping_weight - floor($usps_shipping_weight)));
    Do you get more accurate rates now?
    Unfortunately, this does not fix the problem, it only makes it worse actually. After observing the differences, it's clear that the suggested edit above causes everything to round down. For example, I just had a package that weighs 6.7 ounces and ZC now decided to charge for only 6 ounces, which means I'm losing money. When I changed it back though, it properly calculated the shipping for 7 ounces.

    So yeah, there's still some real issues going on here with the USPS module... hoping these can get resolved for a future release.

  10. #10
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    67,213
    Plugin Contributions
    6

    Default Re: USPS Rounding Errors -- Should never round down

    What settings do you have on the Shipping/Packaging ...

    What is the exact weight that you are using on the Product for the 1 ounce?
    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: v1.5.3]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. product quanitites cause VAT Rounding Errors
    By guyp in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 6 Jun 2008, 11:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •