I'm using USPS rate quotes with Drupal 7.26 and Ubercart 3.6. I have weights set for all of my products but errors are thrown when multiple products are in the cart during checkout. The quotes are returned fine if only one product is in the cart even if the quantity of the product is greater than one.

I have tired adjusting the maximum package quantity and set dimensions for the products but the error persists.

Notice: Undefined property: stdClass::$weight in _uc_usps_package_products() (line 677 of /var/www/html/sites/all/modules/ubercart/shipping/uc_usps/uc_usps.module).
Notice: Undefined property: stdClass::$weight in _uc_usps_package_products() (line 677 of /var/www/html/sites/all/modules/ubercart/shipping/uc_usps/uc_usps.module).
Notice: Undefined property: stdClass::$weight in _uc_usps_package_products() (line 680 of /var/www/html/sites/all/modules/ubercart/shipping/uc_usps/uc_usps.module).
Notice: Undefined property: stdClass::$weight in _uc_usps_package_products() (line 681 of /var/www/html/sites/all/modules/ubercart/shipping/uc_usps/uc_usps.module).

Below is the debug message:

Please enter the package weight. 
API=RateV4&XML=<RateV4Request USERID="XXXXXXXX"><Revision>2</Revision><Package ID="0"><Service>ALL</Service><ZipOrigination>61761</ZipOrigination><ZipDestination>81004</ZipDestination><Pounds>0</Pounds><Ounces>0.0</Ounces><Container>VARIABLE</Container><Size>REGULAR</Size><Width>0</Width><Length>0</Length><Height>0</Height><Girth>0</Girth><Value>46.9</Value><Machinable>FALSE</Machinable><ReturnLocations>TRUE</ReturnLocations><ShipDate Option="EMSH">12-Apr-2014</ShipDate></Package></RateV4Request>

<?xml version="1.0" encoding="UTF-8"?>
<RateV4Response><Package ID="0"><Error><Number>-2147219500</Number><Source>DomesticRatesV4;clsRateV4.ValidateWeight;RateEngineV4.ProcessRequest</Source><Description>Please enter the package weight.  </Description><HelpFile/><HelpContext>1000440</HelpContext></Error></Package></RateV4Response>
Members fund testing for the Drupal project. Drupal Association Learn more


knerrmj’s picture

The error seems to only occur when the option "All products in one package" is selected from the quote options. The error does not occur when the option "Each product in its own package" is selected. However, selecting "Each product in its own package" returns a quote that is multiplied by the number of unique products in the cart and thus makes it an unsuitable workaround.

knerrmj’s picture

I was able to fix this issue by adding the following line to the function _uc_usps_new_package after line 931 in the uc_usps.module file:

$package->weight = 0;

I am not at all familiar with writing patches or I would submit one. Would someone be willing to write a patch for this?

TR’s picture

Priority: Normal » Minor

That's a small change that won't hurt anything, but I'm curious as to why you're the only one seeing this - that code hasn't been modified in years. What version of PHP are you running? What contributed modules do you have installed? Anything you can think of which distinguishes your site from a new/clean installation of Ubercart? "All in one" is the default, so I would expect that everyone using USPS would have this problem, but this is the first report we've seen.

TR’s picture

Issue summary: View changes
gukudrupal’s picture


Looks like this is happening on my shop as well. We had changes made on the default pick up page and that messed things up.

I used the fix option from #2 and it worked.

sah62’s picture

Same situation here. I recently upgraded my server from Ubuntu 12.04 LTS to Ubuntu 14.04.1 LTS (with PHP Version 5.5.9-1ubuntu4.3) and this issue started appearing for non-logged-in users. I'm using Drupal 7.31 and Ubercart 7.x-3.6.

I can reproduce it reliably. Is there anything I can do or share to assist with debugging? I'm also using the Ubercart Discount Coupons and Ubercart Out of stock Notification modules.

sah62’s picture

Version: 7.x-3.6 » 7.x-3.7
Priority: Minor » Normal

I'm going to ask to bump this up to normal priority. I can reliably reproduce it in version 7.x-3.7:

Shop as an anonymous user.
Add two or more items to your cart.
Calculate USPS shipping costs from the cart page.

When I do this I get the logged error message described above and the shipping costs are not displayed.

sah62’s picture

Patch attached.

sah62’s picture

Version: 7.x-3.7 » 7.x-3.8

I'm still experiencing this issue with 7.x-3.8.

sah62’s picture

Version: 7.x-3.8 » 7.x-3.9
Component: Shipping » Code
Status: Active » Needs review

This issue is still present in 7.x-3.9.

DamienMcKenna’s picture

Version: 7.x-3.9 » 7.x-3.x-dev
Status: Needs review » Reviewed & tested by the community

Seems simple.

andsub’s picture

This issue is still present in 7.x-3.10

joelstein’s picture

I experienced the same error and the patch in #8 fixed this for me. Let's see it committed! :)

kkasson’s picture

This issue happens for me when there are two or more products in the cart, those products have shipping addresses that are not the same as the default store address, and the packaging options are set to group all items into the same package.

I did some investigating and found that the problem seems to be that the function _uc_usps_package_products is returning an array containing two packages: the first one is empty and the second one contains all of the items. Looking at the code for that function, it seems that the array is being initialized and set to a new package at line 637. Then it checks to see if any of the provided addresses are the same as the default address. In this case they're not, so at line 658 a new array item is added using the products' shipping address. The problem is that the original array element then remains empty and causes the error later.

I've attached a patch I'm using as a workaround. Before returning the package array it checks if the first element is full of zero values, and just removes it if so.

kkasson’s picture

Status: Reviewed & tested by the community » Needs review