Hacked By AnonymousFox

Current Path : /home/krishnamexports/www/ajax/
Upload File :
Current File : /home/krishnamexports/www/ajax/addtoCartBulk.php

<?php

session_start();

//session_destroy();

include('../config/database.php');			

$productId    = $_POST['productId'];

$productqty   = $_POST['productqty'];

$productsize2 = $_POST['productsize2'];

$productsize  = array();	

if(isset($_POST['productsize']))

{

	$productsize  = $_POST['productsize'];	

}



$sqlProduct     = mysqli_query($cn,"select * from `tbl_product` where `id`='".$productId."'");

$sqlProductData = mysqli_fetch_array($sqlProduct);

if($sqlProductData['bulk_order']==1)

{		

	$status         = 0;

	$msg            = "WISHLIST ADDED.";

	

	if(count(array_filter($productsize))==0)

	{		

		$status = 2;			

		$msg    = "SELECT ATLEAST ONE SIZE.";					

		$arr    = array('status'=>$status, 'msg'=>$msg);	

		echo json_encode($arr);

	}

	else

	{

		

		$sizeArray = array();

		for($j=0;$j<count($productsize2);$j++)

		{

			array_push($sizeArray, array("size"=>$productsize2[$j], "qty"=>$productqty[$j]));			

		}					

		if($status==0)

		{

			if(isset($_SESSION['kxproductList']))

			{					

				$_SESSION['kxproductListTemp'] = array();

				$_SESSION['kxproductListAll']  = array();

				for($i=0;$i<count($productsize);$i++)

				{					

					$key = array_search($productsize[$i], array_column($sizeArray, 'size'));																	

					$qty = $sizeArray[$key]['qty'];						

					array_push($_SESSION['kxproductListTemp'],array("productId" =>$productId, "qty"=>$qty, "polishId"=>"", "sizeId"=>$productsize[$i],  "productName"=>$sqlProductData['name'], "productPrice"=>currencyPrice($sqlProductData['price']), "productPhoto"=>productDefaultPhoto($productId), "productSlugURL"=>$sqlProductData['slug_url']));															

				}

				foreach($_SESSION['kxproductList'] as $pL)

				{

					array_push($_SESSION['kxproductListAll'],array("productId" =>$pL['productId'], "qty"=>$pL['qty'], "polishId"=>$pL['polishId'], "sizeId"=>$pL['sizeId'], "productName"=>$pL['productName'], "productPrice"=>$pL['productPrice'], "productPhoto"=>$pL['productPhoto'], "productSlugURL"=>$pL['productSlugURL']));

				}

								

				$productStatus = 1;

				foreach($_SESSION['kxproductListTemp'] as $pLT)

				{						

					$search_items = array('productId'=>$pLT['productId'], 'polishId'=>$pLT['polishId'], 'sizeId'=>$pLT['sizeId']);

					$res = search($_SESSION['kxproductList'], $search_items);									

					if(count(array_filter($res))==0)

					{						

						$status        = 4;			

						$msg           = "Enquiry List Updated Successfully.";

						array_push($_SESSION['kxproductListAll'],array("productId" =>$productId, "qty"=>$pLT['qty'], "polishId"=>$pLT['polishId'], "sizeId"=>$pLT['sizeId'], "productName"=>$pLT['productName'], "productPrice"=>$pLT['productPrice'], "productPhoto"=>$pLT['productPhoto'], "productSlugURL"=>$pLT['productSlugURL']));																						

					}					

				}																						

																	

				$subTotal = 0; $deliveryCharges = 0; $orderTotal = 0;																														

				$_SESSION['kxproductList2'] = array();

				foreach($_SESSION['kxproductListAll'] as $pL)

				{				

					$sqlProduct2     = mysqli_query($cn,"select * from `tbl_product` where `id`='".$pL['productId']."'");

					$sqlProductData2 = mysqli_fetch_array($sqlProduct2);

					$subTotal        = $subTotal + ($pL['qty'] * $sqlProductData2['price']);	

					$deliveryCharges = $deliveryCharges + $sqlProductData2['delivery_charge'];					

					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

			{

				$_SESSION['kxproductList'] = array();		

				for($i=0;$i<count($productsize);$i++)

				{					

					$key = array_search($productsize[$i], array_column($sizeArray, 'size'));																	

					$qty = $sizeArray[$key]['qty'];					

					array_push($_SESSION['kxproductList'],array("productId" =>$productId, "qty"=>$qty, "polishId"=>"", "sizeId"=>$productsize[$i],  "productName"=>$sqlProductData['name'], "productPrice"=>currencyPrice($sqlProductData['price']), "productPhoto"=>productDefaultPhoto($productId)));

				}				

				$subTotal = 0; $deliveryCharges = 0; $orderTotal = 0;

				$_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);

					$subTotal        = $subTotal + ($pL['qty'] * $sqlProductData2['price']);	

					$deliveryCharges = $deliveryCharges + $sqlProductData2['delivery_charge'];

					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

		{

				

		}

	}				

}

else

{

	$status = 5;

	$msg    = "Somethig Went Wrong. Try Again.";

	$arr    = array('status'=>$status, 'msg'=>$msg);	

	echo json_encode($arr);

}

?>

Hacked By AnonymousFox1.0, Coded By AnonymousFox