-
Notifications
You must be signed in to change notification settings - Fork 1
/
qtydown.php
47 lines (46 loc) · 1.39 KB
/
qtydown.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
<?php
session_start();
require "config.php";
require "models/db.php";
require "models/product.php";
require "models/manufacture.php";
require "models/protype.php";
require "models/cart.php";
require "models/user.php";
$product = new Product();
$manu = new Manufacture();
$type = new Protype();
$cart = new Cart();
$user = new User();
if (isset($_SESSION['user'])) {
# code...
if (isset($_GET['id'])) {
# code...
$id = $_GET['id'];
$sl = $_POST['qty'];
if (isset($_SESSION['cart'][$id])) {
# code...
$qty = $_SESSION['cart'][$id] - 1;
} else {
$qty = $sl;
}
$_SESSION['cart'][$id] = $qty;
# code...
$check = $user->check($_SESSION['user']);
foreach ($check as $values) {
foreach ($_SESSION['cart'] as $key => $qty) {
$getProductById = $product->getProductById($id);
foreach ($getProductById as $value) {
if ($key == $value['id']) {
if ($checkProduct_id = $cart->checkProduct_id($key)) {
if ($cart->UpdateQty($qty + $sl - 1, $key)) {
# code...
header("location:viewcart.php");
}
}
}
}
}
}
}
}