You are here

function commerce_xquantity_uninstall in Commerce Extended Quantity 8

Implements hook_uninstall().

Update order item quantity field storage definition.

File

./commerce_xquantity.install, line 109
Install, update and uninstall functions for the xquantity module.

Code

function commerce_xquantity_uninstall() {
  $update_manager = \Drupal::entityDefinitionUpdateManager();
  $entity_type = $update_manager
    ->getEntityType('commerce_order_item');
  $update_manager
    ->installFieldStorageDefinition('quantity', 'commerce_order_item', 'commerce_order', OrderItem::baseFieldDefinitions($entity_type)['quantity']);
  $config = \Drupal::configFactory();
  foreach ($config
    ->listAll('core.entity_form_display.commerce_order_item.') as $id) {
    $editable = $config
      ->getEditable($id);
    $data = $editable
      ->getRawData();
    unset($data['content']['quantity']['settings']['disable_on_cart']);
    $editable
      ->setData($data);
    $editable
      ->save();
  }
}