diff --git a/modules/order/commerce_order.post_update.php b/modules/order/commerce_order.post_update.php index 335c6cf399..26dd36ceba 100644 --- a/modules/order/commerce_order.post_update.php +++ b/modules/order/commerce_order.post_update.php @@ -5,6 +5,8 @@ * Post update functions for Order. */ +use Drupal\Core\Entity\Entity\EntityFormDisplay; + /** * Revert Order views to fix broken Price fields. */ @@ -149,3 +151,22 @@ function commerce_order_post_update_5() { return $message; } + +/** + * Update the profile address field. + */ +function commerce_order_post_update_6() { + // Remove the default_country setting from any profile form. + // That allows Commerce to apply its own default taken from the store. + $query = \Drupal::entityQuery('entity_form_display')->condition('targetEntityType', 'profile'); + $ids = $query->execute(); + $form_displays = EntityFormDisplay::loadMultiple($ids); + foreach ($form_displays as $id => $form_display) { + /** @var \Drupal\Core\Entity\Display\EntityDisplayInterface $form_display */ + if ($component = $form_display->getComponent('address')) { + $component['settings'] = []; + $form_display->setComponent('address', $component); + $form_display->save(); + } + } +} diff --git a/modules/order/config/install/core.entity_form_display.profile.customer.default.yml b/modules/order/config/install/core.entity_form_display.profile.customer.default.yml index 059953af85..bf41ed4964 100644 --- a/modules/order/config/install/core.entity_form_display.profile.customer.default.yml +++ b/modules/order/config/install/core.entity_form_display.profile.customer.default.yml @@ -17,7 +17,7 @@ content: address: type: address_default weight: 0 - settings: - default_country: 'site_default' + settings: { } third_party_settings: { } + region: content hidden: { }