-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcart.php
240 lines (193 loc) · 7.75 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<?php
session_start();
if ($_SESSION["customer-login"] != "true") {
header('Location: login.php');
}
?>
<!DOCTYPE html>
<html lang="en">
<?php
require_once("connect-db.php");
$sql = "SELECT * FROM customer_order inner join menu on menu.menu_id = customer_order.menu_id where customer_order.customer_id = :customer_id";
$statement = $db->prepare($sql);
$statement->bindValue(":customer_id", $_SESSION["customer_id"]);
if ($statement->execute()) {
$menu = $statement->fetchAll();
$statement->closeCursor();
} else {
$message = "<h3>Error retrieving cart.</h3>";
}
?>
<?php
$message = "";
require_once("connect-db.php");
$sql = "SELECT * FROM customer WHERE customer_id = :customer_id";
$statement = $db->prepare($sql);
$statement->bindValue(":customer_id", $_SESSION["customer_id"]);
if ($statement->execute()) {
$customer = $statement->fetchAll();
$statement->closeCursor();
$message = "<h3>Menu was successfully retrieved.</h3>";
} else {
$message = "<h3>Error retrieving menu.</h3>";
}
?>
<!--adding total price for items in cart.-->
<?php
foreach ($menu as $m) {
$price = $m["price"];
$tax = 1.05;
$total += number_format($price * $tax, 2);
}
?>
<head>
<meta charset="UTF-8">
<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-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe"
crossorigin="anonymous"></script>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<link rel="icon" href="taco_truck.jpg" type="image/x-icon">
<title>Ted's Taco Truck</title>
</head>
<body>
<div class="container">
<?php include("header.html"); ?>
<?php include("nav.html"); ?>
<section>
<div class="row">
<div class="col-md-12">
<h3 class="right">Items in your cart.</h3>
</div>
</div>
</section>
<article>
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-5">
<table class="table table-striped order">
<thead>
<tr>
<th scope="col"></th>
<th scope="col">Menu Item</th>
<th scope="col">Price</th>
</tr>
<?php
foreach ($menu as $m) {
?>
<tr id="order_description">
<td><img class="food" src="<?php echo $m["image"]; ?>"></td>
<td>
<?php echo $m["menu_item"]; ?>
</td>
<td>
<?php echo "$";
echo $m["price"]; ?>
</td>
</tr>
<tr>
<td class="text-center">
<form action="remove.php" method="GET">
<input type="hidden" name="customer_order_id"
value="<?php echo $m["customer_order_id"]; ?>">
<button type="submit" class="btn btn-danger">Remove From Cart</button>
</form>
</td>
<?php
}
?>
</thead>
</table>
</div>
<div class="col-md-4"></div>
</div>
</article>
<article>
<div class="row">
<div class="col-md-1"></div>
<div class="col-md-5 box4" id="bill">
<h3>Billing Information</h3>
<?php
foreach ($customer as $c) {
?>
<ul>
<li>First Name:
<?php echo $c["fname"]; ?>
</li>
<li>Last Name:
<?php echo $c["lname"]; ?>
</li>
<li>Billing Address:
<?php echo $c["shipping"]; ?>
</li>
<li>Credit Card Type:
<?php echo $c["credit_card_type"]; ?>
</li>
<li>Card Number:
<?php echo $c["card_number"]; ?>
</li>
<form action="customer-edit.php" method="POST">
<input type="hidden" name="customer_id"
value="<?php echo $_SESSION["customer_id"]; ?>"><br><br>
<button type="submit">Update Billing Information</button>
</form>
</ul>
<?php
}
?>
</div>
<div class=col-md-1></div>
<div class="col-md-5" id="bill">
<div>
<?php
foreach ($menu as $m) {
$price = $m["price"];
?>
<h3>$
<?php echo $price; ?>
</h3>
<?php
}
?>
</div>
<h3 class="under">$
<?php echo $total; ?>--Total Cost
</h3>
</div>
</div>
</article>
<article>
<div class="row">
<div class="col-md-5"></div>
<div class="col-md-3">
<h3>Check Out</h3>
<form action="checkout.php" method="POST"> <!-- Use POST method -->
<?php
foreach ($menu as $m) {
?>
<input type="hidden" name="menu_ids[]" value="<?php echo $m["customer_order_id"]; ?>">
<?php
}
?>
<input type="hidden" name="customer_id" value="<?php echo $_SESSION["customer_id"]; ?>">
<button onclick="return confirm('Does this complete your order?')" type="submit" class="btn btn-primary" name="submit_order">Submit Order</button>
</form>
</div>
<div class="col-md-5"></div>
</div>
</article>
<aside>
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-4">
<h5>Click here to <a href="menu.php">return to Menu</a></h5>
</div>
<div class="col-md-6"></div>
</div>
</aside>
<?php include("footer.html"); ?>
</div>
</body>
</html>