You are here

function commerce_wishlist_update_8305 in Commerce Wishlist 8.3

Add the 'is_public' and 'keep_purchased_items' fields to wishlists.

File

./commerce_wishlist.install, line 140
Contains install and update functions for Commerce Wishlist.

Code

function commerce_wishlist_update_8305() {
  $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  $storage_definition = BaseFieldDefinition::create('boolean')
    ->setLabel(t('Public'))
    ->setDisplayOptions('form', [
    'type' => 'boolean_checkbox',
    'settings' => [
      'display_label' => TRUE,
    ],
    'weight' => 19,
  ]);
  $definition_update_manager
    ->installFieldStorageDefinition('is_public', 'commerce_wishlist', 'commerce_wishlist', $storage_definition);
  $storage_definition = BaseFieldDefinition::create('boolean')
    ->setLabel(t('Keep purchased items in the list'))
    ->setDefaultValue(TRUE)
    ->setDisplayOptions('form', [
    'type' => 'boolean_checkbox',
    'settings' => [
      'display_label' => TRUE,
    ],
    'weight' => 20,
  ])
    ->setDisplayConfigurable('form', TRUE);
  $definition_update_manager
    ->installFieldStorageDefinition('keep_purchased_items', 'commerce_wishlist', 'commerce_wishlist', $storage_definition);
}