You are here

function commerce_promotion_post_update_7 in Commerce Core 8.2

Add the condition_operator field to promotions.

File

modules/promotion/commerce_promotion.post_update.php, line 178
Post update functions for Promotion.

Code

function commerce_promotion_post_update_7() {
  $storage_definition = BaseFieldDefinition::create('list_string')
    ->setLabel(t('Condition operator'))
    ->setDescription(t('The condition operator.'))
    ->setRequired(TRUE)
    ->setSetting('allowed_values', [
    'AND' => t('All conditions must pass'),
    'OR' => t('Only one condition must pass'),
  ])
    ->setDisplayOptions('form', [
    'type' => 'options_buttons',
    'weight' => 4,
  ])
    ->setDisplayConfigurable('form', TRUE)
    ->setDefaultValue('AND');
  $entity_definition_update = \Drupal::entityDefinitionUpdateManager();
  $entity_definition_update
    ->installFieldStorageDefinition('condition_operator', 'commerce_promotion', 'commerce_promotion', $storage_definition);
}