You are here

function dc_ajax_add_cart_update_quantity in Commerce Ajax Add to Cart 7

Same name and namespace in other branches
  1. 7.2 dc_ajax_add_cart.module \dc_ajax_add_cart_update_quantity()

Update line item quantity.

Parameters

object $line_item: Line item.

See also

dc_ajax_add_cart_update_quantity_refresh()

4 string references to 'dc_ajax_add_cart_update_quantity'
dc_ajax_add_cart_ajax_cart_settings_form in ./dc_ajax_add_cart.admin.inc
Commerce AJAX Add to Cart settings form.
dc_ajax_add_cart_forms in ./dc_ajax_add_cart.module
Implements hook_forms().
dc_ajax_add_cart_uninstall in ./dc_ajax_add_cart.install
Implements hook_uninstall().
template_preprocess_dc_ajax_shopping_cart in ./dc_ajax_add_cart.module
Add more variables to shopping cart block.

File

./dc_ajax_add_cart.module, line 688
Ajax add to cart module.

Code

function dc_ajax_add_cart_update_quantity($form, &$form_state, $line_item) {
  $form = array();
  $form['quantity_' . $line_item->line_item_id] = array(
    '#type' => 'textfield',
    '#size' => 3,
    '#maxlength' => 3,
    '#default_value' => intval($line_item->quantity),
  );
  $form['submit_' . $line_item->line_item_id] = array(
    '#type' => 'submit',
    '#value' => t('Update'),
    '#line_item_id' => $line_item->line_item_id,
    '#ajax' => array(
      'callback' => 'dc_ajax_add_cart_update_quantity_refresh',
      'method' => 'replace',
    ),
  );
  $form['#submit'][] = 'dc_ajax_add_cart_rebuild_update_quantity_form';
  return $form;
}