Problem/Motivation

PHP error on checkout page under these conditions:

  • Shippingable products
  • Shipping method with a condition on an address
  • Workflow settings for checkout: shipping - do not hide shipping

When shipping address form initially built no address exists but shipping method conditions are evaluated.

Proposed resolution

Check for null address in condition evaluation and return false.

Error Logged

TypeError: Argument 1 passed to CommerceGuys\Addressing\Zone\Zone::match() must implement interface CommerceGuys\Addressing\AddressInterface, null given, called in /var/www/drupalvm/drupal/web/modules/contrib/commerce_shipping/src/Plugin/Commerce/Condition/ShipmentAddress.php on line 83 in CommerceGuys\Addressing\Zone\Zone->match() (line 93 of /var/www/drupalvm/drupal/vendor/commerceguys/addressing/src/Zone/Zone.php) #0 /var/www/drupalvm/drupal/web/modules/contrib/commerce_shipping/src/Plugin/Commerce/Condition/ShipmentAddress.php(83): CommerceGuys\Addressing\Zone\Zone->match(NULL)

CommentFileSizeAuthor
#2 2927898-1.patch818 bytestroseman

Comments

troseman created an issue. See original summary.

troseman’s picture

StatusFileSize
new818 bytes
troseman’s picture

Status: Active » Needs review
bojanz’s picture

Title: Error if not hiding shipping initially and address conditions on shipping method » The ShipmentAddress condition crashes when the shipping profile has no address yet

  • bojanz committed abbea74 on 8.x-2.x authored by troseman
    Issue #2927898 by troseman, bojanz: The ShipmentAddress condition...
bojanz’s picture

Status: Needs review » Fixed

Added a test, and committed. Thanks!

Status: Fixed » Closed (fixed)

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