addAddressAttributes breaks existing shipping address edit form

Created on 6 July 2023, almost 2 years ago
Updated 22 July 2024, 9 months ago

Problem/Motivation

When the commerce_stripe module is enabled and when on checkout page we try to edit the existing shipping address and changing country the form is not rebuilt and contains fields for the previous country address.

Steps to reproduce

Enable commerce_stripe, commerce_shipping. Configure an order type and product variations to use shipping. Add product to the cart and complete the checkout process with selected checkbox to save the shipping address to the address book. Try to add the product again to the cart and proceed to checkout step where the shipping information form is displayed. Try to edit the saved shipping address by using the inline form. Let's say the saved address country is 'United Kingdom'. The address should contain required field Postal code. Try to change country which doesn't require postal code e.g. Togo. The ajax animation icon should appear under the country field, but the form shouldn't refreshed according to the selected country. In recent log messages you should see the errors:

TypeError: implode(): Argument #1 ($pieces) must be of type array, string given in implode() (line 1119 of /var/www/html/web/core/lib/Drupal/Core/Form/FormState.php)
#0 /var/www/html/web/core/lib/Drupal/Core/Form/FormState.php(1119): implode('][', NULL)
Warning: Undefined array key "#parents" in Drupal\Core\Form\FormState->setError() (line 1119 of /var/www/html/web/core/lib/Drupal/Core/Form/FormState.php)
#0 /var/www/html/web/core/includes/bootstrap.inc(347): _drupal_error_handler_real(2, 'Undefined array...', '/var/www/html/w...', 1119)

Proposed resolution

Add conditions to Drupal\commerce_stripe\PluginForm\Stripe\PaymentMethodAddForm::addAddressAttributes()to check if the elements are set before adding the attributes.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine khiminrm

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024