-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage_cart.php
42 lines (33 loc) · 1.12 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
<?php
require('connection.inc.php');
require('function.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']);
$productSoldQtyByProductId = productSoldQtyByProductId($con, $pid);
$productQty = productQty($con, $pid);
$pending_qty = $productQty - $productSoldQtyByProductId;
$obj = new add_to_cart(); //if and else condition ma repeat thay che etle condition ni bahar aapi
if ($qty < 1) {
// $obj = new add_to_cart();
if ($type == 'remove') { //remove type if condition ma etle aapyu kem ke jyare security check ma qty minus ma apiye tyare e remove thai sake.
$obj->removeProduct($pid, $qty);
}
} else {
if ($qty > $pending_qty) {
echo "not_available";
die();
}
// $obj = new add_to_cart();
if ($type == 'add') {
$obj->addProduct($pid, $qty);
}
if ($type == 'remove') {
$obj->removeProduct($pid, $qty);
}
if ($type == 'update') {
$obj->updateProduct($pid, $qty);
}
}
echo $obj->totalProduct();