You are here

function commerce_promotion_update_8205 in Commerce Core 8.2

Add the usage_limit_customer field to promotions and coupons.

File

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

Code

function commerce_promotion_update_8205() {
  $entity_definition_update = \Drupal::entityDefinitionUpdateManager();
  $storage_definition = BaseFieldDefinition::create('integer')
    ->setLabel(t('Customer usage limit'))
    ->setDescription(t('The maximum number of times the promotion can be used by a customer. 0 for unlimited.'))
    ->setDefaultValue(0)
    ->setDisplayOptions('form', [
    'type' => 'commerce_usage_limit',
    'weight' => 4,
  ]);
  $entity_definition_update
    ->installFieldStorageDefinition('usage_limit_customer', 'commerce_promotion', 'commerce_promotion', $storage_definition);
  $entity_definition_update
    ->installFieldStorageDefinition('usage_limit_customer', 'commerce_promotion_coupon', 'commerce_promotion', $storage_definition);
}