-
Notifications
You must be signed in to change notification settings - Fork 1
/
cart.php
125 lines (102 loc) · 4.34 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css" integrity="sha512-xh6O/CkQoPOWDdYTDqeRdPCVd1SpvCA9XXcUnZS2FmJNp1coAFzvtCN9BmamE+4aHK8yyUHUSCcJHgXloTyT2A==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="cart.css" />
<link rel="stylesheet" href="navbar.css" />
<link rel="stylesheet" href="footer.css" />
<title>Maida - My cart</title>
</head>
<body>
<!-- NavBar Start -->
<nav id="header">
</nav>
<!-- NavBar End -->
<div class="container">
<div class="row w-100">
<div class="col">
<h1 style="
line-height: 120px;
display: flex;
justify-content: center;
align-items: center;
margin-top: 100px;
">
My Cart
</h1>
<div class="card" style="margin: 20px">
<div class="container" style="height:23rem; overflow-y: scroll;">
<div class="row d-flex justify-content-center" style="padding: 20px">
<?php
session_start();
if (isset($_SESSION['cart'])) {
$cart = $_SESSION['cart'];
$fulltotal = 0;
foreach ($cart as $key => $value) {
$total = (int)$value['price'] * (int)$value['quantity'];
$fulltotal += $total;
echo '
<div id=' . $value['id'] . ' class="ItemContainer row" style="width:95%; border:1px solid orangered; padding:10px; border-radius:5px; margin-bottom:5px;">
<div class="col-2 d-flex align-items-center"><div class="imgcontainer" style="width:100px; height:50px; border-radius:5px; overflow:hidden;"><img width="100px" src="ImageUploads/' . $value['image'] . '"></div></div>
<div class="col-3 d-flex align-items-center">' . $value['name'] . ' <span style ="color:orangered;">x' . $value['quantity'] . '</span></div>
<div class="col-4 d-flex align-items-center text-muted">' . $value['request'] . '</div>
<div class="col-2 d-flex align-items-center" style="color:orangered;">' . $total . 'L.L.</div>
<div class="col-1 d-flex align-items-center justify-content-end">
<i id="delete" class="fa fa-window-close" style="color:red;" aria-hidden="true"></i>
</div>
</div>
';
}
}
?>
</div>
</div>
</div>
<center>
<span style="font-weight:bold; font-size:15pt;">Total:</span><span style="font-size:15pt; color:orangered;"><?php echo $fulltotal ?>L.L.</span>
<br>
<button onclick="location.href='payment.php'" class='btn' style='width:80%; margin-top:50px;background-color:orangered; color:white; font-weight:bold;'>Checkout</button>
</center>
</div>
</div>
</div>
<!-- Footer Start -->
<div id="footer">
</div>
<!-- Footer End -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$("#header").load("navbar.php");
});
</script>
<script type="text/javascript">
$(function() {
$("#footer").load("footer.php");
});
</script>
<script>
$(document).ready(function() {
$(".ItemContainer").on("click", "#delete", function() {
var id = $(this).parent().parent().attr("id");
$.ajax({
url: "delete_cart_item.php",
type: "POST",
data: {
id: id
},
success: function(data) {
if (data == "deleted") {
$("#" + id).remove();
}
}
});
});
});
</script>
</body>
</html>