File "removeToCart.php"

Full Path: /home/krishnamexports/public_html/ajax/removeToCart.php
File size: 2.06 KB
MIME-type: text/x-php; charset=us-ascii
Charset: utf-8

<?php

session_start();

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

$productId = $_GET['productId'];

$polishId  = $_GET['polishId'];

$sizeId    = $_GET['sizeId'];	



$status    = 0;

$msg       = "PRODUCT DELETED SUCCESSFULLY.";



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

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

{

	if(count($_SESSION['kxproductList'])>0)

	{

		$productStatus = 1;

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

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

		{		

			if($pL['productId']==$productId && $pL['polishId']==$polishId && $pL['sizeId']==$sizeId)

			{				

				

			}

			else

			{

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

				$sqlProductData = mysqli_fetch_array($sqlProduct);

				array_push($_SESSION['kxproductList2'],array("productId" =>$pL['productId'], "qty"=>$pL['qty'], "polishId"=>$pL['polishId'], "sizeId"=>$pL['sizeId'], "productName"=>$pL['productName'], "productPrice"=>currencyPrice($sqlProductData['price']), "productPhoto"=>productDefaultPhoto($pL['productId']), "productSlugURL"=>$pL['productSlugURL']));

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

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

			}			

		}

				

		$_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, 'productList'=>$_SESSION['kxproductList']);	

		echo json_encode($arr);	

	}

}

else

{

	$arr    = array('status'=>$status, 'msg'=>$msg, 'productList'=>$_SESSION['kxproductList']);	

	echo json_encode($arr);	

}	

?>