public function addProduct($product_class_id, $quantity) { $objProduct = new SC_Product_Ex(); $arrProduct = $objProduct->getProductsClass($product_class_id); $productTypeId = $arrProduct['product_type_id']; $find = false; $max = $this->getMax($productTypeId); for ($i = 0; $i <= $max; $i++) { if ($this->cartSession[$productTypeId][$i]['id'] == $product_class_id) { $val = $this->cartSession[$productTypeId][$i]['quantity'] + $quantity; if (strlen($val) <= INT_LEN) { $this->cartSession[$productTypeId][$i]['quantity'] += $quantity; } $find = true; } } if (!$find) { $this->cartSession[$productTypeId][$max + 1]['id'] = $product_class_id; $this->cartSession[$productTypeId][$max + 1]['quantity'] = $quantity; $this->cartSession[$productTypeId][$max + 1]['cart_no'] = $this->getNextCartID($productTypeId); } }