-
Notifications
You must be signed in to change notification settings - Fork 0
/
cart_handler.php
55 lines (46 loc) · 1.38 KB
/
cart_handler.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
53
54
55
<?php
include 'database.php';
include 'cartList.php';
include 'user.php';
include 'checkoutClass.php';
session_start();
print_r($_POST);
$dao = new Database();
if(isset($_POST['deleteAll'])){
if(isset($_SESSION['logged_in']) && $_SESSION['logged_in']){
$dao->deleteCart($_SESSION['user']->getAccountID());
echo $_SESSION['user']->getAccountID();
echo 'hello';
//header('Location: cart.php');
}
else{
if(isset($_SESSION['cart'])){
$_SESSION['cart']->emptyCart();
}
//header('Location: cart.php');
exit();
}
}
else if(isset($_POST['checkout'])){
$_SESSION['checkoutInfo'] = new checkOutData($_POST['partIDCheckout'], $_POST['quantity']);
header('Location: checkout.php');
exit();
}
else if(isset($_POST['deleteSelected'])){
if(isset($_SESSION['logged_in']) && $_SESSION['logged_in']){
foreach($_POST['partID'] as $delItem){
$dao->deletePartialCart($_SESSION['user']->getAccountID(), $delItem);
}
//header('Location: cart.php');
exit();
}
else{
if(isset($_SESSION['cart'])){
foreach($_POST['partID'] as $delItem){
$_SESSION['cart']->removeCartItem($delItem);
}
//header('Location: cart.php');
exit();
}
}
}