You are here

function commerce_cart_entity_form_display_alter in Commerce Core 8.2

Implements hook_entity_form_display_alter().

File

modules/cart/commerce_cart.module, line 355
Implements the shopping cart system and add to cart features.

Code

function commerce_cart_entity_form_display_alter(EntityFormDisplayInterface $form_display, array $context) {
  if ($context['entity_type'] != 'commerce_order_item') {
    return;
  }

  // The "add_to_cart" form mode doesn't have a form display yet.
  // Default to hiding the unit_price field.
  if ($context['form_mode'] == 'add_to_cart' && $context['form_mode'] != $form_display
    ->getMode()) {
    $form_display
      ->removeComponent('unit_price');
  }
}