You are here

function uc_ajax_cart_add_item in Ubercart AJAX Cart 6.2

Same name and namespace in other branches
  1. 7.2 uc_ajax_cart.module \uc_ajax_cart_add_item()
1 call to uc_ajax_cart_add_item()
uc_ajax_cart_callback in ./uc_ajax_cart.module

File

./uc_ajax_cart.module, line 141

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);
  uc_product_load($product);
  $formValues = array(
    'values' => $data,
  );
  drupal_execute($data['form_id'], $formValues, $product);
  return;
}