You are here

function uc_cart_view_form_submit in Ubercart 7.3

Same name and namespace in other branches
  1. 5 uc_cart/uc_cart.module \uc_cart_view_form_submit()
  2. 6.2 uc_cart/uc_cart.module \uc_cart_view_form_submit()

Default submit handler for uc_cart_view_form().

See also

uc_cart_view_form()

2 string references to 'uc_cart_view_form_submit'
uc_cart_view_form in uc_cart/uc_cart.module
Displays the contents of the customer's cart.
uc_paypal_ec_form in payment/uc_paypal/uc_paypal.module
Returns the form for Express Checkout Shortcut Flow.

File

uc_cart/uc_cart.module, line 707

Code

function uc_cart_view_form_submit($form, &$form_state) {

  // If a remove button was clicked, set the quantity for that item to 0.
  if (substr($form_state['triggering_element']['#name'], 0, 7) == 'remove-') {
    $item = substr($form_state['triggering_element']['#name'], 7);
    $form_state['values']['items'][$item]['qty'] = 0;
    drupal_set_message(t('<strong>!product-title</strong> removed from your shopping cart.', array(
      '!product-title' => $form['items'][$item]['title']['#markup'],
    )));
  }

  // Update the items in the shopping cart based on the form values, but only
  // if a qty has changed.
  foreach ($form['items'] as $key => $item) {
    if (isset($item['qty']['#default_value']) && $item['qty']['#default_value'] != $form_state['values']['items'][$key]['qty']) {
      uc_cart_update_item_object((object) $form_state['values']);
    }
  }
}