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
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 2925470-1.patch | 717 bytes | sorabh.v6 |
Comments
Comment #2
sorabh.v6Comment #3
sorabh.v6Comment #4
heddnLooks good here.
Comment #5
bojanz commentedChanging 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.
Comment #6
luksakI 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.
Comment #7
bojanz commented#6 proves my point. There's a bug further up the stack.
Comment #8
rlangille commentedWith 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
Comment #9
dobe commentedI have issues that this patch resolved. I have done migration where not all addresses are available. I believe this patch is a valid fix.
Comment #10
mglamanIt 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.
Comment #11
bojanz commentedNote that we're fixing the #9 use case in #3009618: Tax crashes if the customer profile has no address.