Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
ajax
:
addtoCart.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php session_start(); //session_destroy(); include('../config/database.php'); $productId = $_GET['productId']; $qty = $_GET['qty']; $polishId = $_GET['polishId']; $sizeId = $_GET['sizeId']; //$stoneId = $_GET['stoneId']; $sqlProduct = mysqli_query($cn,"select * from `tbl_product` where `id`='".$productId."'"); $sqlProductData = mysqli_fetch_array($sqlProduct); $productPolish = explode("$",$sqlProductData['polish_id']); $productSize = explode("$",$sqlProductData['size_id']); //$productStone = explode("$",$sqlProductData['stone_id']); $status = 0; $msg = "ENQUIRY ADDED."; /*if(count($productStone)>0) { if(empty($stoneId)) { $status = 1; $msg = "Select Stone"; } }*/ if(count(array_filter($productSize))>0) { if(empty($sizeId)) { $status = 2; $msg = "SELECT SIZE."; } } if(count(array_filter($productPolish))>0) { if(empty($polishId)) { $status = 3; $msg = "SELECT POLISH TYPE"; } } $subTotal = 0; $deliveryCharges = 0; $orderTotal = 0; if($status==0) { if(isset($_SESSION['kxproductList'])) { if(count($_SESSION['kxproductList'])>0) { $productStatus = 1; foreach($_SESSION['kxproductList'] as $pL) { if($pL['productId']==$productId && $pL['polishId']==$polishId && $pL['sizeId']==$sizeId) { $productStatus = 2; $status = 4; $msg = "Product Already Into Enquiry List."; } else { $sqlProduct1 = mysqli_query($cn,"select * from `tbl_product` where `id`='".$pL['productId']."'"); $sqlProductData1 = mysqli_fetch_array($sqlProduct1); $subTotal = $subTotal + ($pL['qty'] * $sqlProductData1['price']); $deliveryCharges = $deliveryCharges + $sqlProductData1['delivery_charge']; } } if($productStatus==1) { $subTotal = $subTotal + ($qty * $sqlProductData['price']); $deliveryCharges = $deliveryCharges + $sqlProductData['delivery_charge']; array_push($_SESSION['kxproductList'],array("productId" =>$productId, "qty"=>$qty, "polishId"=>$polishId, "sizeId"=>$sizeId, "productName"=>$sqlProductData['name'], "productPrice"=>currencyPrice($sqlProductData['price']), "productPhoto"=>productDefaultPhoto($productId), "productSlugURL"=>$sqlProductData['slug_url'])); } } else { $subTotal = $subTotal + ($qty * $sqlProductData['price']); $deliveryCharges = $deliveryCharges + $sqlProductData['delivery_charge']; array_push($_SESSION['kxproductList'],array("productId" =>$productId, "qty"=>$qty, "polishId"=>$polishId, "sizeId"=>$sizeId, "productName"=>$sqlProductData['name'], "productPrice"=>currencyPrice($sqlProductData['price']), "productPhoto"=>productDefaultPhoto($productId))); } } else { $_SESSION['kxproductList'] = array(); $subTotal = $subTotal + ($qty * $sqlProductData['price']); $deliveryCharges = $deliveryCharges + $sqlProductData['delivery_charge']; array_push($_SESSION['kxproductList'],array("productId" =>$productId, "qty"=>$qty, "polishId"=>$polishId, "sizeId"=>$sizeId, "productName"=>$sqlProductData['name'], "productPrice"=>currencyPrice($sqlProductData['price']), "productPhoto"=>productDefaultPhoto($productId))); } $_SESSION['kxproductList2'] = array(); foreach($_SESSION['kxproductList'] as $pL) { $sqlProduct2 = mysqli_query($cn,"select * from `tbl_product` where `id`='".$pL['productId']."'"); $sqlProductData2 = mysqli_fetch_array($sqlProduct2); array_push($_SESSION['kxproductList2'],array("productId" =>$pL['productId'], "qty"=>$pL['qty'], "polishId"=>$pL['polishId'], "sizeId"=>$pL['sizeId'], "productName"=>$sqlProductData2['name'], "productPrice"=>currencyPrice($sqlProductData2['price']), "productPhoto"=>productDefaultPhoto($sqlProductData2['id']), "productSlugURL"=>$sqlProductData2['slug_url'])); } $_SESSION['kxproductList'] = array(); $_SESSION['kxproductList'] = $_SESSION['kxproductList2']; $orderTotal = $subTotal + $deliveryCharges; $arr = array('status'=>$status, 'msg'=>$msg, 'productCount'=>count($_SESSION['kxproductList']), 'subTotal'=>currencyPrice($subTotal), 'deliveryCharges'=>currencyPrice($deliveryCharges), 'orderTotal'=>currencyPrice($orderTotal), 'productList'=>$_SESSION['kxproductList']); echo json_encode($arr); } else { $arr = array('status'=>$status, 'msg'=>$msg); echo json_encode($arr); } ?>