$left = db_fetch_row($q); if ($left["in_stock"] < 1) { $rediractflag = true; db_query("DELETE FROM " . SHOPPING_CARTS_TABLE . " WHERE customerID=" . regGetIdByLogin($_SESSION["log"]) . " AND itemID=" . (int) $cartItem["id"]); db_query("DELETE FROM " . SHOPPING_CART_ITEMS_TABLE . " where itemID=" . (int) $cartItem["id"]); db_query("DELETE FROM " . SHOPPING_CART_ITEMS_CONTENT_TABLE . " where itemID=" . (int) $cartItem["id"]); db_query("DELETE FROM " . ORDERED_CARTS_TABLE . " where itemID=" . (int) $cartItem["id"]); } } else { // if quick ordering $productID = $cartItem["id"]; $q = db_query("select name, in_stock FROM " . PRODUCTS_TABLE . " WHERE productID=" . (int) $productID); $left = db_fetch_row($q); if ($left["in_stock"] < 1) { $rediractflag = true; $res = DeCodeItemInClient($productID); $i = SearchConfigurationInSessionVariable($res["variants"], $res["productID"]); if ($i != -1) { $_SESSION["gids"][$i] = 0; } } } } if ($rediractflag) { Redirect("index.php?product_removed=yes"); } } $orderID = ordOrderProcessing($_GET["shippingMethodID"], $_GET["paymentMethodID"], $_GET["shippingAddressID"], $_GET["billingAddressID"], $shippingModuleFiles, $paymentModuleFiles, $_POST["order_comment"], $cc_number, $cc_holdername, $cc_expires, $cc_cvv, $_SESSION["log"], $smarty_mail, $shServiceID); $_SESSION["newoid"] = $orderID; cartClearCartContet(); if (is_bool($orderID)) {
$productID = GetProductIdByItemId(str_replace("count_", "", $key)); $is = GetProductInStockCount($productID); if ($val > 0) { //$val is a new items count in the shopping cart if (CONF_CHECKSTOCK == 1) { $val = min($val, $is); } //check stock level $q = db_query("UPDATE " . SHOPPING_CARTS_TABLE . " SET Quantity=" . floor($val) . " WHERE customerID=" . regGetIdByLogin($_SESSION["log"]) . " AND itemID=" . (int) str_replace("count_", "", $key)); } else { //$val<=0 => delete item from cart $q = db_query("DELETE FROM " . SHOPPING_CARTS_TABLE . " WHERE customerID=" . regGetIdByLogin($_SESSION["log"]) . " AND itemID=" . (int) str_replace("count_", "", $key)); } } else { //session vars $res = DeCodeItemInClient(str_replace("count_", "", $key)); $is = GetProductInStockCount($res["productID"]); if ($val > 0) { $i = SearchConfigurationInSessionVariable($res["variants"], $res["productID"]); //check stock level if (CONF_CHECKSTOCK == 1) { $val = min($val, $is); } $_SESSION["counts"][$i] = floor($val); } else { //remove $i = SearchConfigurationInSessionVariable($res["variants"], $res["productID"]); $_SESSION["gids"][$i] = 0; } } }