You are here

function commerce_xquantity_update_8201 in Commerce Extended Quantity 8

Update XquantityOrderItem 'quantity' field definition.

File

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

Code

function commerce_xquantity_update_8201() {
  $update_manager = \Drupal::entityDefinitionUpdateManager();
  $quantity = $update_manager
    ->getFieldStorageDefinition('quantity', 'commerce_order_item');
  if ($quantity
    ->getType() != 'xdecimal') {
    $entity_type = $update_manager
      ->getEntityType('commerce_order_item');
    $update_manager
      ->installFieldStorageDefinition('quantity', 'commerce_order_item', 'commerce_order', XquantityOrderItem::baseFieldDefinitions($entity_type)['quantity']);
    return t('Order item quantity field successfully updated to xdecimal type.');
  }
  return t('Order item quantity field does not need to be updated as that is of xdecimal type.');
}