function m_updateCart($checkout = '0') { $comFunc = new c_commonFunctions(); $comFunc->obDb = $this->obDb; $libFunc = new c_libFunctions(); $totalQty = 0; $cntItems = count($this->request['cartid']); #TOTAL ITEMS IN CART for ($i = 0; $i < $cntItems; $i++) { $update = 1; if (!isset($this->request['qty'][$i]) || empty($this->request['qty'][$i]) || !is_numeric($this->request['qty'][$i]) || $this->request['qty'][$i] < 1) { $this->request['qty'][$i] = 1; } $iTmpCartId = $this->request['cartid'][$i]; $iQty = $this->request['qty'][$i]; $iProdId = $this->m_getProductId($iTmpCartId); $comFunc->productId = $iProdId; $this->m_getTotalQty($iProdId); #Total of product quantity except the the current item;s quantity. $this->m_getTotalQty($iProdId, 1, $iTmpCartId); $_SESSION['backorder'][$iProdId] = 0; #MAIN STOCK CHECK -SETTINGS FROM FEATURES if (STOCK_CHECK == 1) { #TO CHECK STOCK CONTROL ENABLED FOR PRODUCT if ($this->iUseinventory == 1 && !$this->is_options($iProdId)) { $qtyAvailable = $this->iInventory - $this->totalQtyInTemp; if ($qtyAvailable < $this->request['qty'][$i]) { if ($this->iBackorder == 1) { $_SESSION['backorder'][$iProdId] = 1; } else { $this->request['qty'][$i] = $qtyAvailable; $this->errMsg .= "<li>" . $this->libFunc->m_displayContent($this->vTitle) . "</li>"; $update = 0; } } #quantity check $displayOptChoice = 1; } #end inventory check $displayOptChoice = 1; #QUANTITY CHECK ON OPTIONS foreach ($_POST as $field => $fieldValue) { $fArray = explode('_', $field); $cnt = count($fArray); if ($cnt == 2) { $fieldId = $fArray[1]; #GET OPTION ID } elseif ($cnt == 3) { $fieldId = $fArray[2]; #GET OPTION ID $prodId = $fArray[1]; #GET PROD } #$iProdId product id according to cartid #$prodId product id according to options/choice if ($fArray[0] == 'option') { if ($iProdId == $prodId) { $qtyAvailable = $this->m_getOptionQty($prodId, $fieldValue, $iTmpCartId); #TO CHECK STOCK CONTROL ENABLED if ($this->iUseinventory == 1) { if ($qtyAvailable < $this->request['qty'][$i] - $this->carttotalqty) { if ($this->iBackorder == 1) { $_SESSION['backorder'][$iProdId] = 1; } else { $this->request['qty'][$i] = $qtyAvailable; $this->errMsg .= "<li>" . $this->libFunc->m_displayContent($this->vTitle) . " - option(" . $this->libFunc->m_displayContent($this->vOptTitle) . ")</li>"; $update = 0; } } } } } /* if($fArray[0]=='choice' && !empty($fieldValue)) { if($iProdId==$prodId) { $qtyAvailable=$this->m_getChoiceQty($prodId,$fieldId); #TO CHECK STOCK CONTROL ENABLED if($this->iUseinventory==1) { if($qtyAvailable<$this->request['qty'][$i]) { if($this->iBackorder==1) { $_SESSION['backorder'][$iProdId]=1; } else { $this->request['qty'][$i]=$qtyAvailable; $this->errMsg.="<li>".$this->vTitle." - choice(".$this->vOptTitle.")</li>"; $update=0; } } } } }*/ } } #end main stock check $totalQty += $this->request['qty'][$i]; if ($this->request['qty'][$i] < 1) { $this->request['qty'][$i] = 1; } if ($update == 1) { $vDiscoutPerItem = $comFunc->m_dspCartProductVolDiscount($this->request['qty'][$i]); $this->obDb->query = "UPDATE " . TEMPCART . " SET iQty='" . $this->request['qty'][$i] . "',"; $this->obDb->query .= "fVolDiscount='" . $vDiscoutPerItem . "'"; $this->obDb->query .= " WHERE (iTmpCartId_PK='" . $this->request['cartid'][$i] . "')"; $this->obDb->updateQuery(); } } $_SESSION['totalQty'] = $totalQty; if (!empty($this->errMsg)) { return false; } if ($checkout == 1) { $this->Interface->checkout = 1; $this->Interface->template = $this->templatePath . "viewcart.tpl.htm"; $this->Interface->m_viewCart(); exit; } else { $retUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=ecom.viewcart"); $this->libFunc->m_mosRedirect($retUrl); exit; } }