I'm getting this notice whenever a customer gets a USPS shipping quote during the checkout process. The order includes two products with package parameters for both set to 7x5x1 inches. Shipping quote options are set to "All products in one package". Package type for each product is "Variable".

Notice: Undefined property: stdClass::$girth in /home/muscl1/public_html/sites/all/modules/ubercart/shipping/uc_usps/uc_usps.module on line 463

#8 1926054.patch411 bytesTR
PASSED: [[SimpleTest]]: [MySQL] 2,839 pass(es). View
#6 ubercart_usps_girth-1926054-2.patch1.13 KBsah62
PASSED: [[SimpleTest]]: [MySQL] 2,837 pass(es). View
#4 ubercart_usps_girth-1926054-2.patch1.15 KBsah62
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in ubercart_usps_girth-1926054-2.patch. View
#1 ubercart_usps_girth-1926054-1.patch1.12 KBDanZ
PASSED: [[SimpleTest]]: [MySQL] 2,837 pass(es). View


DanZ’s picture

Status:Active» Needs review
new1.12 KB
PASSED: [[SimpleTest]]: [MySQL] 2,837 pass(es). View

Try this (completely untested) patch and see if it helps.

I'm not sure if this is a complete fix for the problem, but it might help you in the short term.

See https://www.usps.com/business/web-tools-apis/rate-calculators-v1-7a.htm for details.

sah62’s picture

Thanks for the tip. As-is the patch produces a malformed request that looks like this (note that the opening tag for the Package element is missing):

<RateV4Request USERID="MYID"><Revision>2</Revision><Value>23</Value><Machinable>FALSE</Machinable><ReturnLocations>TRUE</ReturnLocations><ShipDate Option="EMSH">24-Feb-2013</ShipDate></Package></RateV4Request>

I tweaked the code a little differently and got it to work. Here's what it looks like with my change in place:

    for ($i = 0; $i < $qty; $i++) {
      if ($package->size == 'LARGE') {
        $package_dims = '<Width>' . $package->width . '</Width>' .
          '<Length>' . $package->length . '</Length>' .
          '<Height>' . $package->height . '</Height>' .
          '<Girth>' . $package->girth . '</Girth>';
      else {
        $package_dims = '';
      $request .= '<Package ID="' . $package_id . '">' .
        '<Service>' . ($rate_type ? 'ONLINE' : 'ALL') . '</Service>' .
        '<ZipOrigination>' . substr(trim($origin->postal_code), 0, 5) . '</ZipOrigination>' .
        '<ZipDestination>' . substr(trim($destination->postal_code), 0, 5) . '</ZipDestination>' .
        '<Pounds>' . intval($package->pounds) . '</Pounds>' .
        '<Ounces>' . number_format($package->ounces, 1, '.', '') . '</Ounces>' .
        '<Container>' . $package->container . '</Container>' .
        '<Size>' . $package->size . '</Size>' .
        $package_dims .
        '<Value>' . $package->price . '</Value>' .

I won't claim that it's the best way to do it, but as I said it seems to work.

DanZ’s picture

Looks like #1 needs some parentheses.

sah62’s picture

new1.15 KB
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in ubercart_usps_girth-1926054-2.patch. View

Yup, adding parentheses resolved the problem.

Status:Needs review» Needs work

The last submitted patch, ubercart_usps_girth-1926054-2.patch, failed testing.

sah62’s picture

new1.13 KB
PASSED: [[SimpleTest]]: [MySQL] 2,837 pass(es). View

Fixed line endings in the patch file.

sah62’s picture

Status:Needs work» Needs review

Fixing issue status...

TR’s picture

Priority:Normal» Minor
new411 bytes
PASSED: [[SimpleTest]]: [MySQL] 2,839 pass(es). View

This bug was introduced just recently by #1364508: USPS error: Dimensions are missing for package; unable to calculate postage., which is why I REALLY do not like to see changes committed unless there's a real patch, not just a few lines of suggested text. A real patch ensures the testbot will look at it, and catch stupid things like this. I moved this to minor because it's a PHP Notice that doesn't appear to the customer.

A simpler fix is just to ensure that girth is initialized, just like width, length, and height are. Please try this out and see if it eliminates the notice.

sah62’s picture

Much simpler, and yes, it eliminates the warning. Thanks!

DanZ’s picture

Status:Needs review» Reviewed & tested by the community

The testbot and sah62 seem to like it, so RTBC.

TR’s picture

Status:Reviewed & tested by the community» Fixed

Okay then. Committed patch from #8. Thanks for the bug report.

sah62’s picture

Thanks for the fix.

longwave’s picture

Testbot would not have caught this anyway, as there are no tests for USPS. I did not commit it blindly either; I now have a USPS account precisely so I could test the outstanding patches in this queue before committing. Unfortunately, I did not catch this case!

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary:View changes

Added note about product package type.