From a3d594c9ac314d8379d333b6328cf43ce2c1d270 Mon Sep 17 00:00:00 2001 From: Bojan Zivanovic Date: Wed, 13 Sep 2017 17:26:22 +0200 Subject: [PATCH] Issue #2908568 by bojanz: Remove the "Site default" default country from the profile address field --- modules/order/commerce_order.post_update.php | 21 +++++++++++++++++++ ..._form_display.profile.customer.default.yml | 4 ++-- 2 files changed, 23 insertions(+), 2 deletions(-) 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: { }