Skip to content

Commit a3d594c

Browse files
committed
Issue #2908568 by bojanz: Remove the "Site default" default country from the profile address field
1 parent 477c7f2 commit a3d594c

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

modules/order/commerce_order.post_update.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* Post update functions for Order.
66
*/
77

8+
use Drupal\Core\Entity\Entity\EntityFormDisplay;
9+
810
/**
911
* Revert Order views to fix broken Price fields.
1012
*/
@@ -149,3 +151,22 @@ function commerce_order_post_update_5() {
149151

150152
return $message;
151153
}
154+
155+
/**
156+
* Update the profile address field.
157+
*/
158+
function commerce_order_post_update_6() {
159+
// Remove the default_country setting from any profile form.
160+
// That allows Commerce to apply its own default taken from the store.
161+
$query = \Drupal::entityQuery('entity_form_display')->condition('targetEntityType', 'profile');
162+
$ids = $query->execute();
163+
$form_displays = EntityFormDisplay::loadMultiple($ids);
164+
foreach ($form_displays as $id => $form_display) {
165+
/** @var \Drupal\Core\Entity\Display\EntityDisplayInterface $form_display */
166+
if ($component = $form_display->getComponent('address')) {
167+
$component['settings'] = [];
168+
$form_display->setComponent('address', $component);
169+
$form_display->save();
170+
}
171+
}
172+
}

modules/order/config/install/core.entity_form_display.profile.customer.default.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ content:
1717
address:
1818
type: address_default
1919
weight: 0
20-
settings:
21-
default_country: 'site_default'
20+
settings: { }
2221
third_party_settings: { }
22+
region: content
2323
hidden: { }

0 commit comments

Comments
 (0)