You are here

function commerce_promotion_update_8204 in Commerce Core 8.2

Add the display_name field to promotions.

File

modules/promotion/commerce_promotion.install, line 125
Install, update and uninstall functions for the commerce_promotion module.

Code

function commerce_promotion_update_8204() {
  $entity_definition_update = \Drupal::entityDefinitionUpdateManager();
  $storage_definition = BaseFieldDefinition::create('string')
    ->setLabel(t('Display name'))
    ->setDescription(t('If provided, shown on the order instead of "@translated".', [
    '@translated' => t('Discount'),
  ]))
    ->setTranslatable(TRUE)
    ->setSettings([
    'display_description' => TRUE,
    'default_value' => '',
    'max_length' => 255,
  ])
    ->setDisplayOptions('form', [
    'type' => 'string_textfield',
    'weight' => 0,
  ])
    ->setDisplayConfigurable('view', TRUE)
    ->setDisplayConfigurable('form', TRUE);
  $entity_definition_update
    ->installFieldStorageDefinition('display_name', 'commerce_promotion', 'commerce_promotion', $storage_definition);
}