You are here

public function UcAjaxCart::addItemToCart in Ubercart AJAX Cart 7.2

Same name and namespace in other branches
  1. 6.2 uc_ajax_cart.php \UcAjaxCart::addItemToCart()

File

./uc_ajax_cart.extender.inc, line 37

Class

UcAjaxCart

Code

public function addItemToCart($nodeID, $qty = 1, $data = array()) {
  $node = node_load($nodeID);
  if (!is_object($node) || !uc_product_is_product($node)) {
    throw new NoProductException();
  }

  /** @todo this should come over form. or this field is populated by submit handler. **/
  $data['nid'] = $nodeID;
  if ($node->type == 'product_kit') {
    return $this
      ->addItemKitToCart($nodeID, $qty, $data);
  }
  uc_cart_add_item($node->nid, $qty, module_invoke_all('add_to_cart_data', $data), null, true, false, true);
  return;
}