-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage_cart.php
52 lines (40 loc) · 1.09 KB
/
manage_cart.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
require('connection.inc.php');
require('functions.inc.php');
require('add_to_cart.inc.php');
$pid=get_safe_value($con,$_POST['pid']);
$qty=get_safe_value($con,$_POST['qty']);
$type=get_safe_value($con,$_POST['type']);
$attr_id=0;
if(isset($_POST['sid']) && isset($_POST['cid'])){
$sub_sql='';
$sid=get_safe_value($con,$_POST['sid']);
$cid=get_safe_value($con,$_POST['cid']);
if($sid>0){
$sub_sql.=" and size_id=$sid ";
}
if($cid>0){
$sub_sql.=" and color_id=$cid ";
}
$row=mysqli_fetch_assoc(mysqli_query($con,"select id from product_attributes where product_id='$pid' $sub_sql"));
$attr_id=$row['id'];
}
$productSoldQtyByProductId=productSoldQtyByProductId($con,$pid,$attr_id);
$productQty=productQty($con,$pid,$attr_id);
$pending_qty=$productQty-$productSoldQtyByProductId;
if($qty>$pending_qty && $type!='remove'){
echo "not_avaliable";
die();
}
$obj=new add_to_cart();
if($type=='add'){
$obj->addProduct($pid,$qty,$attr_id);
}
if($type=='remove'){
$obj->removeProduct($pid,$attr_id);
}
if($type=='update'){
$obj->updateProduct($pid,$qty,$attr_id);
}
echo $obj->totalProduct();
?>