Problem/Motivation

I am trying to set default shipping method from the cart page, where we do not have shipping profile. And when I click on the checkout page, it gives me an error -

TypeError: Argument 1 passed to Drupal\commerce_tax\TaxZone::match() must implement interface CommerceGuys\Addressing\AddressInterface, null given, called in /var/www/Acro/5280-scuba/web/modules/contrib/commerce/modules/tax/src/Plugin/Commerce/TaxType/LocalTaxTypeBase.php on line 278 in Drupal\commerce_tax\TaxZone->match() (line 138 of /var/www/Acro/5280-scuba/web/modules/contrib/commerce/modules/tax/src/TaxZone.php) #0 /var/www/Acro/5280-scuba/web/modules/contrib/commerce/modules/tax/src/Plugin/Commerce/TaxType/LocalTaxTypeBase.php(278): Drupal\commerce_tax\TaxZone->match(NULL) #1 /var/www/Acro/5280-scuba/web/modules/contrib/commerce/modules/tax/src/Plugin/Commerce/TaxType/LocalTaxTypeBase.php(253): Drupal\commerce_tax\Plugin\Commerce\TaxType\LocalTaxTypeBase->resolveZones(Object(Drupal\commerce_order\Entity\OrderItem), Object(Drupal\profile\Entity\Profile))

Proposed resolution

$address should be optional in public function match(AddressInterface $address)

Attaching patch for the work.

Thanks

CommentFileSizeAuthor
#2 2925470-1.patch717 bytessorabh.v6

Comments

sorabh.v6 created an issue. See original summary.

sorabh.v6’s picture

StatusFileSize
new717 bytes
sorabh.v6’s picture

Status: Active » Needs review
heddn’s picture

Status: Needs review » Reviewed & tested by the community

Looks good here.

bojanz’s picture

Status: Reviewed & tested by the community » Needs review

Changing this would be a BC break at this point.

Why are we invoking TaxZone::match() with an empty object? Sounds to me like there's a problem in one of the layers above.

luksak’s picture

I keep getting this error when having the patches needed for #2844920: Allow customer profiles to be reused ar applied and the user navigates back and forth in the checkout process. This patch prevents a WSOD, but doesn't solve the actual issue.

bojanz’s picture

Status: Needs review » Closed (won't fix)

#6 proves my point. There's a bug further up the stack.

rlangille’s picture

With the patches for reuse profile there's a case for anonymous users that edit their shipping profile getting into this state.

I submitted a patch to help out with that case (short term fix - there are better ways to do this).

https://www.drupal.org/project/commerce_shipping/issues/2955938

dobe’s picture

Status: Closed (won't fix) » Reviewed & tested by the community

I have issues that this patch resolved. I have done migration where not all addresses are available. I believe this patch is a valid fix.

mglaman’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

It was marked Won't Fix in #7 because there is a bigger bug upstream.

Same with #9: your migration data is incomplete. So you'll need a way for those orders to skip having tax calculated on them during the migration. Or provide more details.

bojanz’s picture

Note that we're fixing the #9 use case in #3009618: Tax crashes if the customer profile has no address.