public static function getPriceInfo() { global $lC_Product; if (!isset($lC_Product)) { $lC_Product = new lC_Product($_GET['id']); } $result = $lC_Product->getPriceInfo($_GET['id'], $_GET['group'], $_GET); if ($result !== false) { $result['rpcStatus'] = RPC_STATUS_SUCCESS; } echo json_encode($result); }
public function update($item_id, $quantity) { global $lC_Database, $lC_Customer, $lC_Services; if (!is_numeric($quantity)) { $quantity = $this->getQuantity($item_id); } $this->_contents[$item_id]['quantity'] = $quantity; if ($lC_Customer->isLoggedOn()) { $Qupdate = $lC_Database->query('update :table_shopping_carts set quantity = :quantity where customers_id = :customers_id and item_id = :item_id'); $Qupdate->bindTable(':table_shopping_carts', TABLE_SHOPPING_CARTS); $Qupdate->bindInt(':quantity', $quantity); $Qupdate->bindInt(':customers_id', $lC_Customer->getID()); $Qupdate->bindInt(':item_id', $item_id); $Qupdate->execute(); } // get default tax_class_id $Qproduct = $lC_Database->query('select products_tax_class_id as tax_class_id from :table_products where products_id = :products_id and products_status = :products_status'); $Qproduct->bindTable(':table_products', TABLE_PRODUCTS); $Qproduct->bindInt(':products_id', $this->_contents[$item_id]['id']); $Qproduct->bindInt(':products_status', 1); $Qproduct->execute(); if ($Qproduct->numberOfRows() === 1) { $this->_contents[$item_id]['tax_class_id'] = $Qproduct->valueInt('tax_class_id'); } $simple_options = array(); if (isset($this->_contents[$item_id]['simple_options'])) { foreach ($this->_contents[$item_id]['simple_options'] as $key => $val) { $simple_options[$val['group_id']] = $val['value_id']; } } // we get the product price from the product class - price already includes options, etc. if (!isset($lC_Product)) { $lC_Product = new lC_Product($this->_contents[$item_id]['id']); } $this->_contents[$item_id]['price_data'] = $lC_Product->getPriceInfo($this->_contents[$item_id]['id'], $lC_Customer->getCustomerGroup(), array('quantity' => $quantity, 'simple_options' => $simple_options)); $this->_contents[$item_id]['price'] = $this->_contents[$item_id]['price_data']['price']; $this->_cleanUp(); $this->_calculate(); return $this->_contents[$item_id]['price_data']; }