My setup:

Drupal core 8.8.3
Commerce Shipping 8.x-2.0-rc1
Commerce USPS 8.x-1.3

I just noticed that USPS International shipping seems to be broken with the most recent releases of Commerce Shipping and Commerce USPS. I'm getting this error in my Watchdog log when trying to manually add a shipment to Italy for an order. I can create the shipment, but when I try to edit it to select a shipping service I get this error:

ArgumentCountError: Too few arguments to function Drupal\commerce_usps\USPSRateRequestBase::getRates(), 1 passed in /var/www/mysite/web/modules/contrib/commerce_usps/src/Plugin/Commerce/ShippingMethod/USPSInternational.php on line 77 and exactly 2 expected in Drupal\commerce_usps\USPSRateRequestBase->getRates() (line 97 of /var/www/mysite/web/modules/contrib/commerce_usps/src/USPSRateRequestBase.php)

Looking at the code in USPSInternational.php:

return $this->uspsRateService->getRates($shipment);

and USPSRateRequestBase.php:

public function getRates(ShipmentInterface $commerce_shipment, ShippingMethodInterface $shipping_method) {

The call to getRates() in USPSInternational.php is missing the $shipping_method parameter. I thought I might be able to fix that by setting the shipping method prior to calling getRates():

$shipping_method = $shipment->getShippingMethod();
return $this->uspsRateService->getRates($shipment, $shipping_method);

but the value I get for $shipping_method is NULL. Can anyone help with a fix?

Comments

sah62 created an issue. See original summary.

sah62’s picture

Issue summary: View changes
sah62’s picture

Issue summary: View changes
sah62’s picture

StatusFileSize
new759 bytes

I found what I believe to be a fix in the USPS.php code:

return $this->uspsRateService->getRates($shipment, $this->parentEntity);

Here's a patch.

Sigh, sorry, wrong patch.

sah62’s picture

StatusFileSize
new589 bytes

This time with the correct patch file...

sah62’s picture

CubbyOne’s picture

I am new to Drupal and Drupal Commerce so forgive me if I am being naive here. I have a similar setup:

Drupal core 8.8.3
Commerce Shipping 8.x-2.0-rc1
Commerce USPS 8.x-1.3

USPS Shipping method/rate is not displaying on the checkout page.

When I check the error log I see this:

<?xml version="1.0" encoding="UTF-8"?> <RateV4Response><Package ID="1"><Error><Number>-2147219098</Number><Source>RateEngineV4;RateV4.ProcessRequest</Source><Description>Missing value for Pounds.</Description><HelpFile/><HelpContext/></Error></Package></RateV4Response>

Any Idea what this means and what do I need to do.
Please help.

CubbyOne’s picture

I am new to Drupal and Drupal Commerce so forgive me if I am being naive here. I have a similar setup:

Drupal core 8.8.3
Commerce Shipping 8.x-2.0-rc1
Commerce USPS 8.x-1.3

USPS Shipping method/rate is not displaying on the checkout page.

When I check the error log I see this:
<?xml version="1.0" encoding="UTF-8"?> <RateV4Response><Package ID="1"><Error><Number>-2147219098</Number><Source>RateEngineV4;RateV4.ProcessRequest</Source><Description>Missing value for Pounds.</Description><HelpFile/><HelpContext/></Error></Package></RateV4Response>

Any Idea what this means and what do I need to do, please?

nno’s picture

Had the same issue. Your patch fixed it. Thank you.

mglaman’s picture

Version: 8.x-1.3 » 8.x-1.x-dev
Status: Active » Needs review

So it looks like #5 fixes the incorrect code call, caused by #3109828: Update for Shipping 2.0-rc1. Sorry I missed this.

But it also seems the parentEntity might be null and causing an error

rhovland’s picture

Priority: Normal » Critical
Status: Needs review » Reviewed & tested by the community

With the updates to make commerce_usps compatible with commerce_shipping rc1 the additional argument needed for getRates() in the USPSInternational plugin was missed.

https://git.drupalcode.org/project/commerce_usps/-/commit/55d5c5312be4bf...

The patch by sah62 fixes this. I discussed this issue with mglaman and after testing the patch I can confirm the issue is resolved with the above patch.

sah62’s picture

I've been using the patch myself now since March. It seems to work fine and I've seen no other errors.

mglaman’s picture

Assigned: Unassigned » mglaman
Status: Reviewed & tested by the community » Fixed

I'm so sorry I missed this in the first fix. Apologies everyone. Thanks @sah62 for the fix, and @rhovland for verifying.

@CubbyOne can you open a different issue? it seems to be something else.

  • mglaman committed 6528146 on 8.x-1.x authored by sah62
    Issue #3119931 by sah62, nno, rhovland: Too few arguments to function...
mglaman’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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