Some Drupal Commerce setups may not have "billing profile" attached to an order.

It's an uncommon situation, but there is a patch that makes it possible.

When someone tries to complete his Order without Billing profile attached to it, he gets an error:
Error: Call to a member function get() on null в Drupal\commerce_google_analytics\EventSubscriber\SendOrderAnalyticsSubscriber->buildGaPushParams() line 56.

There's no real reason to assume that Billing profile is present and to mandatory collect some fields:

       'city' => $profileAddress->getLocality(),
        'region' => $profileAddress->getAdministrativeArea(),
        'country' => $profileAddress->getCountryCode(),

They are optional and we should add it if they're present.

CommentFileSizeAuthor
#2 2977516-Make_Addres_optional.patch2.38 KBSAVEL
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

SAVEL created an issue. See original summary.

SAVEL’s picture

Status: Active » Needs review
FileSize
2.38 KB
Sophie.SK’s picture

Status: Needs review » Reviewed & tested by the community

The patch applied perfectly and works very well. Thanks!

In our case, we set up direct debits during checkout. Payment shouldn't be taken for direct debits at checkout, and if they don't add a shipping method or a non-direct debit product, then there is no billing profile to take the address from.

Berdir’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

Already committed a fix for this in another issue.