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;
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  */
 public function execute($entity = NULL)
 {
     uc_cart_add_item($entity->id(), 1, NULL, NULL, TRUE, FALSE, TRUE);
 }