You are here

function commerce_order_post_update_6 in Commerce Core 8.2

Update the profile address field.

File

modules/order/commerce_order.post_update.php, line 93
Post update functions for Order.

Code

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();
    }
  }
}