Skip to content

Commit

Permalink
Issue #2908568 by bojanz: Remove the "Site default" default country f…
Browse files Browse the repository at this point in the history
…rom the profile address field
  • Loading branch information
bojanz committed Sep 13, 2017
1 parent 477c7f2 commit a3d594c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
21 changes: 21 additions & 0 deletions modules/order/commerce_order.post_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Post update functions for Order.
*/

use Drupal\Core\Entity\Entity\EntityFormDisplay;

/**
* Revert Order views to fix broken Price fields.
*/
Expand Down Expand Up @@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ content:
address:
type: address_default
weight: 0
settings:
default_country: 'site_default'
settings: { }
third_party_settings: { }
region: content
hidden: { }

0 comments on commit a3d594c

Please sign in to comment.