/** * This function is used to get product quantity from db. * * * * @return void */ function getProductQtyForProduct() { if ($_SESSION['user_id'] != '') { // check wheter cart is exists for the user $cartid = Core_CAddCart::getCartIdOfUser(); if ($cartid != 0) { //check the product id and cart id available in the scpt $sql = "SELECT product_id,cart_id,product_qty FROM shopping_cart_products_table WHERE product_id='" . (int) $_GET['prodid'] . "' and cart_id='" . $cartid . "'"; //if(yes) if ($query->executeQuery($sql)) { $req_qty = $query->records[0]['product_qty']; $sql_soh = 'select soh from product_inventory_table where product_id=' . (int) $_GET['prodid']; $query_soh = new Bin_Query(); $query_soh->executeQuery($sql_soh); $soh_product = $query_soh->records[0]['soh']; $dispproduct = $soh_product - $req_qty; } } } else { $sql_soh = 'select soh from product_inventory_table where product_id=' . (int) $_GET['prodid']; $query_soh = new Bin_Query(); $query_soh->executeQuery($sql_soh); $soh_product = $query_soh->records[0]['soh']; $dispproduct = $soh_product - $_SESSION['mycart'][$_GET['prodid']]['qty']; } return $dispproduct; }