USPS weight error for less than 1 Lb.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 years ago
I am using the USPS shipping calculator API and have confirmed my account with them is setup and works. I am using the http://Production.shippingapis.com/ShippingAPI.dll server, not the test one.

I have one item in my store. It is set as "shippable" and it weighs 0.3 Lb. If I add at least 4 of them to my cart (1.2 lb), everything works fine. The shipping page of the checkout shows all the USPS shipping methods to select from and associated costs.

However, if I only have 1, 2, or 3 items in my cart (0.3, 0.6, or 0.9 lbs respectively), I get an error on the shipping page of the checkout: "USPS Error returned: Error Desc: Please enter the package weight. USPS Help Context: 1000440."

If I change the product's weight to 1lb, then it will work at any quantity.

I need to be able to set my products as weighing less than 1 lb (OR in ounces would be nice too). The store allows me to enter this 0.3 Lb value, but then something goes wrong when it calls the USPS API and the total weight is less than 1 lb.

Please help! I want to use nopCommerce but this is deal breaker for us.

-Colin
14 years ago
Upon more testing, the weight ranges are incorrect for product weight. The fractional weight is being discarded.

0.3 Lb product example:

Items in cart: 1 (0.3 Lb)
USPS Priority cost: ERROR: No weight (should be $4.95 for the 0 to 1 Lb range)

Items in cart: 3 (0.9 Lb)
USPS Priority cost: ERROR: No weight (should be $4.95 for the 0 to 1 Lb range)

Items in cart: 4 (1.2 Lb)
USPS Priority cost: $4.95 (should be $7.60 for the >1 to 2 Lb range)

Items in cart: 7 (2.1 Lb)
USPS Priority cost: $7.60 (should be $9.90 for the >2 to 3 Lb range)

This tells me either the store or the USPS is truncating the Weight value to an integer.
Example: 0.9 Lb = 0 Lb, and 1.2 Lb = 1 Lb.

This is incorrect. It should be: 0.9 Lb = 0.9 Lb, and 1.2 Lb = 1.2 Lb (Or 0.9 Lb = 1 Lb, and 1.2 Lb = 2 Lb, etc)

To be cleaner, can we have an option to enter weight of product in Ounces??
14 years ago
It's a bug. The fractional weight is being discarded. What you can do now is:


1. Open USPSComputationMethod.cs file (Nop.Shipping.USPS project)
2. Replace
int pounds = Convert.ToInt32(Math.Truncate(weight));

with
int pounds = Convert.ToInt32(Math.Truncate(weight));
if (pounds == 0)
pounds = 1;

3. Replace
int pounds2 = pounds / totalPackages;

with
int pounds2 = pounds / totalPackages;
if (pounds2 == 0)
pounds2 = 1;

4. Recomile the project
14 years ago
Was this bug fixed in version 1.40?
14 years ago
No. This bug was found after v1.40 was released.
14 years ago
Alright.  Thank you for letting us know.
14 years ago
Will the USPS calculation work if the unit of measure is set to ounces???

I am trying to calculate the shipping for a CD which is roughly 4 ounces and have set the UOM in the General Config to ounces.  With the USPS set to the production server, I get the following error with 1 product which is 4 ounces in the shopping cart.

     System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> NopSolutions.NopCommerce.Common.NopException: USPS shipping service. Base weight should be set to lb(s) at NopSolutions.NopCommerce.Shipping.Methods.USPS.USPSComputationMethod.CreateRequest(String Username, String Password, ShipmentPackage ShipmentPackage) at NopSolutions.NopCommerce.Shipping.Methods.USPS.USPSComputationMethod.GetShippingOptions(ShipmentPackage ShipmentPackage, String& Error) at NopSolutions.NopCommerce.BusinessLogic.Shipping.ShippingManager.GetShippingOptions(ShoppingCart Cart, Customer customer, Address ShippingAddress, String& Error) in F:\Own\NopCommerce\Solution\Solution\Libraries\Nop.BusinessLogic\Shipping\ShippingManager.cs:line 308 at NopSolutions.NopCommerce.Web.Modules.CheckoutShippingMethodControl.Page_Load(Object sender, EventArgs e) at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) --- End of inner exception stack trace --- at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.checkoutshippingmethod_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\738f65a9\b690072b\App_Web_uqlhwhpu.40.cs:line 0 at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Thanks for any help on this.
14 years ago
USPS calculation requires your weight to be set to pounds.

If you want to use ounces instead, you'll need to customize the code so that it divides your total ounces by 16 before sending to USPS.
14 years ago
chrisgwilliams wrote:
USPS calculation requires your weight to be set to pounds.

If you want to use ounces instead, you'll need to customize the code so that it divides your total ounces by 16 before sending to USPS.


Is there support for this in nopCommerce 1.50?

Specifically, the < 1lb bug and the ability to use ounces instead of pounds with USPS calculation?
14 years ago
???
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.