You are here

function commerce_cart_line_item_delete_form_submit in Commerce Core 7

Submit handler to show the line item delete message.

1 string reference to 'commerce_cart_line_item_delete_form_submit'
commerce_cart_form_alter in modules/cart/commerce_cart.module
Implements hook_form_alter().

File

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

Code

function commerce_cart_line_item_delete_form_submit($form, &$form_state) {
  $line_item_id = $form_state['triggering_element']['#line_item_id'];

  // Get the corresponding wrapper to show the correct title.
  $line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $form_state['line_items'][$line_item_id]);

  // If the deleted line item is a product...
  if (in_array($line_item_wrapper
    ->getBundle(), commerce_product_line_item_types())) {
    $title = $line_item_wrapper->commerce_product->title
      ->value();
  }
  else {
    $title = $line_item_wrapper->line_item_label
      ->value();
  }
  drupal_set_message(t('%title removed from your cart.', array(
    '%title' => $title,
  )));
}