-
Notifications
You must be signed in to change notification settings - Fork 0
/
order.php
289 lines (262 loc) · 12 KB
/
order.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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
<?php
session_start();
require_once("dbcontroller.php");
$db_handle = new DBController();
if (!empty($_GET["action"])) {
switch ($_GET["action"]) {
case "add":
if (!empty($_POST["quantity"])) {
$productByCode = $db_handle->runQuery("SELECT * FROM pizzaproduct WHERE code='" . $_GET["code"] . "'");
$itemArray = array($productByCode[0]["code"] => array('name' => $productByCode[0]["name"], 'code' => $productByCode[0]["code"], 'quantity' => $_POST["quantity"], 'price' => $productByCode[0]["price"], 'image' => $productByCode[0]["image"]));
if (!empty($_SESSION["cart_item"])) {
if (in_array($productByCode[0]["code"], array_keys($_SESSION["cart_item"]))) {
foreach ($_SESSION["cart_item"] as $k => $v) {
if ($productByCode[0]["code"] == $k) {
if (empty($_SESSION["cart_item"][$k]["quantity"])) {
$_SESSION["cart_item"][$k]["quantity"] = 0;
}
$_SESSION["cart_item"][$k]["quantity"] += $_POST["quantity"];
}
}
} else {
$_SESSION["cart_item"] = array_merge($_SESSION["cart_item"], $itemArray);
}
} else {
$_SESSION["cart_item"] = $itemArray;
}
}
break;
case "remove":
if (!empty($_SESSION["cart_item"])) {
foreach ($_SESSION["cart_item"] as $k => $v) {
if ($_GET["code"] == $k)
unset($_SESSION["cart_item"][$k]);
if (empty($_SESSION["cart_item"]))
unset($_SESSION["cart_item"]);
}
}
break;
case "empty":
unset($_SESSION["cart_item"]);
break;
}
}
?>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="https://fonts.googleapis.com/css2?family=Cedarville+Cursive&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<!-- Bootstrap core CSS -->
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/shop-homepage.css" rel="stylesheet">
<link href="css/bootstrap-form-helpers.min.css" rel="stylesheet">
<script src="vendor/bootstrapformhelpers/js/bootstrap-formhelpers.min.js"></script>
<link href="vendor/bootstrapformhelpers/css/bootstrap-formhelpers.min.css" rel="stylesheet">
<title>
Store
</title>
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
<div class="container">
<a class="navbar-brand" href="#">Select item</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="index.php">Home
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.php">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="services.php">Services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.php">Contact</a>
</li>
<li class="nav-item">
<a class="nav-link" href="order.php">Order</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container h-20">
<div class="row h-20 justify-content-center align-items-center">
<div class="mr-10 p-5 text-center font-weight-bold">Order Form</div>
</div>
</div>
<a class="btnEmpty" href="index.php?action=empty">Empty Cart</a>
<?php
if (isset($_SESSION["cart_item"])) {
$total_quantity = 0;
$total_price = 0;
?>
<div class="container">
<div class="row">
<div class="col-sm">
Shopping Cart
</div>
</div>
<br />
<div class="row font-weight-bold">
<div class="col-sm">Name</div>
<div class="col-sm">Code</div>
<div class="col-sm">Quantity</div>
<div class="col-sm">Unit Price</div>
<div class="col-sm">Unit Price (Euro)</div>
<div class="col-sm">Price</div>
<div class="col-sm">Price (Euro)</div>
</div>
<br />
<?php
foreach ($_SESSION["cart_item"] as $item) {
$item_price = $item["quantity"] * $item["price"];
?>
<div class="row shop-cart">
<div class="col-sm shop-item"><?php echo $item["name"]; ?></div>
<div class="col-sm shop-item"><?php echo $item["code"]; ?></div>
<div class="col-sm shop-item"><?php echo $item["quantity"]; ?></div>
<div class="col-sm shop-item"><?php echo "$ " . $item["price"]; ?></div>
<div class="col-sm shop-item"><?php echo "€ " . round($item["price"] * 0.87, 2); ?></div>
<div class="col-sm shop-item"><?php echo "$ " . number_format($item_price, 2); ?></div>
<div class="col-sm shop-item"><?php echo "€ " . round(number_format($item_price, 2) * 0.87, 2); ?></div>
<div class="col-sm shop-item"><a href="index.php?action=remove&code=<?php echo $item["code"]; ?>" class="btnRemoveAction">Remove Item</a></div>
</div>
<?php
$total_quantity += $item["quantity"];
$total_price += ($item["price"] * $item["quantity"]);
}
?>
<br />
<div class="row">
<div class="col-sm">Delivery:</div>
<div class="col-sm"><?php echo $total_quantity; ?></div>
<div class="col-sm font-weight-bold"><?php echo "$ " . $total_quantity * 10; ?></div>
<div class="col-sm font-weight-bold"><?php echo "€ " . $total_quantity * 10 * 0.87; ?></div>
</div>
<?php
$total_price_delivery = array(number_format($total_price, 2), $total_quantity * 10);
$total_price_delivery_euro = array(round(number_format($total_price, 2) * 0.87, 2), $total_quantity * 10 * 0.87);
?>
<div class="row">
<div class="col-sm">Total:</div>
<div class="col-sm"><?php echo $total_quantity; ?></div>
<div class="col-sm font-weight-bold"><?php echo "$ " . array_sum($total_price_delivery); ?></div>
<div class="col-sm font-weight-bold"><?php echo "€ " . array_sum($total_price_delivery_euro); ?></div>
</div>
<?php
} else {
?>
<div class="no-records">Your Cart is Empty</div>
<?php
}
?>
</div>
<!------------------------------------ Cart end ------------------------------------>
<br />
<br />
<br />
<div class="container">
<div class=" mx-auto row w-50">
<form class="col d-flex flex-column" action="order.php">
<div class="form-group text-center">
<label for="first_name">First Name:</label>
<input type="text" class="form-control" id="first_name">
</div>
<div class="form-group text-center">
<label for="last_name">Last Name:</label>
<input type="text" class="form-control" id="last_name">
</div>
<div class="form-group text-center">
<label for="email">Email address:</label>
<input type="email" class="form-control" id="email">
</div>
<div class="form-group text-center">
<label for="address">Address:</label>
<input type="text" class="form-control" id="address">
</div>
<div class="form-group text-center">
<label for="phone">Phone Number:</label>
<input type="tel" class="form-control" id="phone">
</div>
<div class="form-group text-center">
<label for="credit_card">Credit Card:</label>
<input type="tel" class="form-control" id="credit_card">
</div>
<div class="checkbox">
<label><input type="checkbox"> Subscribe to Newsletter</label>
</div>
<button type="submit" class="btn btn-secondary font-weight-bold">Submit</button>
</form>
</div>
</div>
<div class="bfh-selectbox bfh-countries" data-country="US" data-flags="true">
</div>
<div>
<p style="font-style: italic; font-family: 'Cedarville Cursive', cursive; text-align: center; font-size: 5em; color: CornflowerBlue;">
Love your pizza!</p>
</div>
<div>
<p style="text-align: center; font-size: 150%;">Join Our 115+ Followers on Social Media</p>
</div>
<div>
<p style="text-align: center; font-size: 150%;">& Share Your Pizza Love! <span style="font-size: 100%; color: CornflowerBlue;">#Pizzalove</span></p>
</div>
<br />
<br />
<br />
<div class="d-flex justify-content-center">
<i class="fa fa-facebook-square img-rounded img-responsive mr-2" style="font-size:48px;color:red"></i>
<i class="fa fa-instagram img-rounded img-responsive mr-2" style="font-size:48px;color:red"></i>
<i class="fa fa-twitter-square img-rounded img-responsive mr-2" style="font-size:48px;color:red"></i>
<i class="fa fa-pinterest-square img-rounded img-responsive mr-2" style="font-size:48px;color:red"></i>
<i class="fa fa-youtube-square img-rounded img-responsive mr-2" style="font-size:48px;color:red"></i>
</div>
<br />
<br />
<br />
<div>
<p style="text-align: center; font-size: 150%;">Looking to learn More? <span style="font-weight: bold">Call</span>, <span style="font-weight: bold">Text</span> or <span style="font-weight: bold">Email us</span>!</p>
<p style="text-align: center; font-size: 150%;">Ready to Order? Visit <span style="font-weight: bold">PizzaPlace.com</span> or give us a call.</p>
</div>
<br />
<br />
<br />
<div>
<p style="color:CornflowerBlue; text-align: center; font-size:300%;">1-800-350-4170</p>
</div>
<br />
<br />
<br />
<div class="container">
<div class="row offset-md-2">
<div class="col-sm text-primary">Update Subscription</div>
<div class="col-sm text-primary">Unsubscribe</div>
<div class="col-sm text-primary">View Online</div>
</div>
</div>
<br />
<br />
<br />
<footer class="py-5 bg-dark">
<div class="container">
<p class="m-0 text-center text-white">Copyright © Pizza Place 2020</p>
<p class="m-0 text-center text-white">1976 Aspen Circle Pueblo, Colorado 81006</p>
</div>
<!-- /.container -->
</footer>
<!-- Bootstrap core JavaScript -->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
</body>
</html>