MMCT TEAM
Server IP : 103.53.40.154  /  Your IP : 3.145.33.244
Web Server : Apache
System : Linux md-in-35.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : ppcad7no ( 715)
PHP Version : 8.2.25
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0750) :  /home2/ppcad7no/lizatilessolution.com/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/ppcad7no/lizatilessolution.com/add_to_cart.php
<?php 
include("includes/dbsmain.inc.php");
include("site-main-query.php");
$site_url=$compDATA['admin_website_url'];
$flag=0;
$Curr_Date = date("Y-m-d");
$check_cart="";
$pro_id=$_REQUEST['pro_cart_id'];
$search_keyword=$_REQUEST['search_keyword'];
if($search_keyword!="")
{
    $search_keyword="?key_search=$search_keyword";
}
$pro_qty=$_REQUEST['qty'];
$size=$_REQUEST['size'];
$color=$_REQUEST['color'];
$area=$_REQUEST['area'];


$pro_sub_total="";
if($pro_qty=="")
{
  $pro_qty=1;
}

if($pro_qty!=""){
$product_QTY_DB=db_scalar("select category_qnty from tbl_category where 1 and category_status='Active' and category_id='$pro_id' ");
if($pro_qty>$product_QTY_DB)
{
$flag=1;
echo "quantity error";
  /*?>
<script>
  alert("Here is only <?=$product_QTY_DB?> left in stock, please enter equal or below <?=$product_QTY_DB?> !");
  window.location.href="<?=$site_url?>/product-detail.html?id=<?=$pro_id?>";
</script>
<?*/
    
    
}
}


if($pro_id!="")
{
  if($flag==0)
{
  if($_SESSION['cart_session_id']!="" && !empty($_SESSION['cart_session_id']))
    {
        ///////////////////////////////////////////
$pro_db_id=db_scalar("select bskt_prd_id from tbl_basket where bskt_prd_id='$pro_id' and bskt_session_id='$_SESSION[cart_session_id]'");
if($pro_db_id!="")
{  
    echo "Sorry ! Item already added in your cart.";
  /*?>
<script>
    alert("Sorry ! Item already added in your cart.");
   // window.location.href="<?=$site_url?>/shopping-cart.html";
     window.location.href="<?=$_SERVER['HTTP_REFERER']?><?=$search_keyword?>";
</script>
<?*/
}else{

if($_REQUEST['from']=="wishlist")
{
  db_query("delete from tbl_wishlist where wishlist_prd_id='$pro_id' and wishlist_reg_id='$_SESSION[login_id]' ");
    }


    $product_sql=db_query("select * from tbl_category where 1 and category_status='Active' and category_id='$pro_id' ");
    $product_data=mysqli_fetch_array($product_sql);
    
    $pro_sub_total=$pro_qty*$product_data['category_discount_price'];

db_query("insert into tbl_basket set 
bskt_session_id='$_SESSION[cart_session_id]',
bskt_prd_id='$pro_id',
bskt_prd_name='$product_data[category_name]',
bskt_prd_image_name='$product_data[category_image_name]',
bskt_prd_qnty='$pro_qty',
size='$size',
color='$color',
area='$area',
bskt_prd_unit_price='$product_data[category_discount_price]',
bskt_prd_subtotal='$pro_sub_total',
bskt_prd_add_date='$Curr_Date'");
echo "Item added in your cart.";
/*?>
<script>
 //   alert("Item added in your cart.");
// window.location.href="<?=$_SERVER['HTTP_REFERER']?><?=$search_keyword?>";
</script>
<?*/

}
        //////////////////////////////////////////
        
    }else{
      
if($_REQUEST['from']=="wishlist")
{
  db_query("delete from tbl_wishlist where wishlist_prd_id='$pro_id' and wishlist_reg_id='$_SESSION[login_id]' ");
    }
      
        $_SESSION['cart_session_id']=rand(100,10000);
      ///////////////////////////////////////////

    $product_sql=db_query("select * from tbl_category where 1 and category_status='Active' and category_id='$pro_id' ");
    $product_data=mysqli_fetch_array($product_sql);

     $pro_sub_total=$pro_qty*$product_data['category_discount_price'];

db_query("insert into tbl_basket set 
bskt_session_id='$_SESSION[cart_session_id]',
bskt_prd_id='$pro_id',
bskt_prd_name='$product_data[category_name]',
bskt_prd_image_name='$product_data[category_image_name]',
bskt_prd_qnty='$pro_qty',
size='$size',
color='$color',
area='$area',
bskt_prd_unit_price='$product_data[category_discount_price]',
bskt_prd_subtotal='$pro_sub_total',
bskt_prd_add_date='$Curr_Date'");

echo "Item added in your cart.";
/*?>
<script>
   alert("Item added in your cart.");
  window.location.href="<?=$_SERVER['HTTP_REFERER']?><?=$search_keyword?>";
</script>
<?*/

        //////////////////////////////////////////
    
    }
    
    }
}


?>

MMCT - 2023