You are here

function uc_ajax_cart_add_item in Ubercart AJAX Cart 7.2

Same name and namespace in other branches
  1. 6.2 uc_ajax_cart.module \uc_ajax_cart_add_item()

@todo Please document this function.

See also

http://drupal.org/node/1354

1 call to uc_ajax_cart_add_item()
uc_ajax_cart_callback in ./uc_ajax_cart.module
@todo Please document this function.

File

./uc_ajax_cart.module, line 207

Code

function uc_ajax_cart_add_item($data) {

  // Protect agains bad calls.
  if (!isset($data['form_id'])) {
    return;
  }
  if (!isset($data['qty'])) {
    $data['qty'] = 1;
  }
  $formID = explode('_', $data['form_id']);
  $nodeID = array_pop($formID);
  $formID = implode('_', $formID);
  $product = node_load($nodeID);
  $formValues = array(
    'values' => $data,
  );
  drupal_form_submit($formID, $formValues, $product);
  return;
}