Error when setting a Payment Gateway condition to a specific country and doing checkout: CommerceGuys\Addressing\Zone\Zone::match(): Argument #1 ($address) must be of type CommerceGuys\Addressing\AddressInterface, null given

Created on 7 February 2023, over 1 year ago

Problem/Motivation

TypeError: CommerceGuys\Addressing\Zone\Zone::match(): Argument #1 ($address) must be of type CommerceGuys\Addressing\AddressInterface, null given, called in /app/web/modules/contrib/commerce/modules/order/src/Plugin/Commerce/Condition/CustomerAddressBase.php on line 77 in CommerceGuys\Addressing\Zone\Zone->match() (line 78 of /app/vendor/commerceguys/addressing/src/Zone/Zone.php)
#0 /app/web/modules/contrib/commerce/modules/order/src/Plugin/Commerce/Condition/CustomerAddressBase.php(77): CommerceGuys\Addressing\Zone\Zone->match(NULL)
#1 /app/web/modules/contrib/commerce/src/ConditionGroup.php(86): Drupal\commerce_order\Plugin\Commerce\Condition\CustomerAddressBase->evaluate(Object(Drupal\commerce_order\Entity\Order))
#2 /app/web/modules/contrib/commerce/modules/payment/src/Entity/PaymentGateway.php(237): Drupal\commerce\ConditionGroup->evaluate(Object(Drupal\commerce_order\Entity\Order))
#3 /app/web/modules/contrib/commerce/modules/payment/src/PaymentGatewayStorage.php(93): Drupal\commerce_payment\Entity\PaymentGateway->applies(Object(Drupal\commerce_order\Entity\Order))
#4 /app/web/modules/contrib/commerce/modules/payment/src/Plugin/Commerce/CheckoutPane/PaymentInformation.php(162): Drupal\commerce_payment\PaymentGatewayStorage->loadMultipleForOrder(Object(Drupal\commerce_order\Entity\Order))
#5 /app/web/modules/contrib/commerce/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowWithPanesBase.php(546): Drupal\commerce_payment\Plugin\Commerce\CheckoutPane\PaymentInformation->buildPaneForm(Array, Object(Drupal\Core\Form\FormState), Array)
#6 [internal function]: Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\CheckoutFlowWithPanesBase->buildForm(Array, Object(Drupal\Core\Form\FormState), 'order_informati...')
#7 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(534): call_user_func_array(Array, Array)
#8 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(281): Drupal\Core\Form\FormBuilder->retrieveForm('commerce_checko...', Object(Drupal\Core\Form\FormState))
#9 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(222): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\MultistepDefault), Object(Drupal\Core\Form\FormState))
#10 /app/web/modules/contrib/commerce/modules/checkout/src/Controller/CheckoutController.php(143): Drupal\Core\Form\FormBuilder->getForm(Object(Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\MultistepDefault), 'order_informati...')
#11 [internal function]: Drupal\commerce_checkout\Controller\CheckoutController->formPage(Object(Drupal\Core\Routing\RouteMatch))
#12 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#13 /app/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#14 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#15 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#16 /app/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#17 /app/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#18 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /app/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /app/web/core/lib/Drupal/Core/DrupalKernel.php(713): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#27 {main}

Steps to reproduce

1. install commerce submodules, commerce_shipping, commerce_packeta
2. set a store to ship to multiple countries
3. set a Packeta shipping method
4. set a regular flat rate shipping method, for example with name Personal pickup
5. add a new payment gateway and call it Bank transfer, check Collect billing information option
6. add a new payment gateway and call it Cash, check Collect billing information option
7. for this Cash payment gateway set a condition: under Customer > check Shipping Address and under Territory set Slovakia as Country
8. add product to cart, start checkout and try to change shipping methods
9. F12 JS dev console should show this every time you change shipping method:

"
An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /checkout/44/order_information?ajax_form=1&_wrapper_format=drupal_ajax
StatusText: OK
ResponseText: TypeError: CommerceGuys\Addressing\Zone\Zone::match(): Argument #1 ($address) must be of type CommerceGuys\Addressing\AddressInterface, null given, called in /app/web/modules/contrib/commerce/modules/order/src/Plugin/Commerce/Condition/CustomerAddressBase.php on line 77 in CommerceGuys\Addressing\Zone\Zone->match() (line 78 of /app/vendor/commerceguys/addressing/src/Zone/Zone.php)."

Now, if you try to reload the page with F5 button (at url like this: http://commerce.localhost/checkout/44/order_information) now WSOD. So because this module right now breaks shipping country condition evaluation, I think I have to raise the priority of this issue.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΈπŸ‡°Slovakia kaszarobert

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024