function commerce_order_update_8213 in Commerce Core 8.2
Add the 'balance' field to the 'default' view mode for all order bundles.
File
- modules/
order/ commerce_order.install, line 256 - Install, update and uninstall functions for the Order module.
Code
function commerce_order_update_8213() {
$bundles = array_keys(\Drupal::service('entity_type.bundle.info')
->getBundleInfo('commerce_order'));
$storage = \Drupal::entityTypeManager()
->getStorage('entity_view_display');
foreach ($bundles as $bundle) {
/** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $default_display */
$default_display = $storage
->load('commerce_order.' . $bundle . '.default');
if (!$default_display) {
continue;
}
$default_display
->setComponent('balance', [
'type' => 'commerce_price_default',
'label' => 'inline',
]);
$default_display
->save();
}
}