-
Notifications
You must be signed in to change notification settings - Fork 0
/
cart.php
69 lines (43 loc) · 1.88 KB
/
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<html>
<head>
<?php include "stylesheets.php" ?>
<link rel = "stylesheet" href = "carn.css?v=">
<script src = "JS/cart.js"></script>
</head>
<body>
<?php
include 'cartList.php';
include "nav.php";
$dao = new Database();
if(isset($_SESSION['logged_in']) && $_SESSION['logged_in']){
if(isset($_SESSION['cart'])){
foreach($_SESSION['cart']->returnCart() as $item){
$dao->addToCart($_SESSION['user']->getAccountID(), $item->getID());
}
$_SESSION['cart'] = NULL;
}
$cartInfo = $dao->getCart($_SESSION['user']->getAccountID());
$cart = new CartList();
if($cartInfo){
foreach($cartInfo as $cartI){
$result = $dao->getPartInfo($cartI['partID']);
$cartPart= new CartItem($result['partID'], $result['imageSrc'],
$result['partName'], $result['partDesc'], $result['stock'], $result['price']);
$cart->addCartItem($cartPart);
}
}
$cart->printCart();
}
else{
if(isset($_SESSION['cart'])){
$_SESSION['cart']->printCart();
}
else{
$_SESSION['cart'] = new CartList();
$_SESSION['cart']->printCart();
}
}
?>
<?php include "footer.php" ?>
</body>
</html>