-
Notifications
You must be signed in to change notification settings - Fork 2
/
order_view.php
370 lines (339 loc) · 12.9 KB
/
order_view.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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
<?php
session_start();
// checking if user is logged in or not
if (!isset($_SESSION['customer'])) {
header("Location: login.php");
}
// including database connection
require('env/database.php');
?>
<!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" />
<title>Order Details</title>
<link rel="icon" type="image/x-icon" href="assets/svg-logo/logo-bg.svg">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" />
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://kit.fontawesome.com/db79afedbd.js" crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" media="screen" href="assets/css/main.css" />
</head>
<body>
<!------------------------------------------------------Loading Screen-------------------------------------------------------- -->
<div id="loading">
<img src="assets/svg-logo/LOADER.svg" alt="Loading..." />
</div>
<script>
var loader = document.getElementById("loading");
window.addEventListener("load", function() {
loader.style.display = "none";
})
</script>
<?php include 'header.php'; ?>
<!-- Body --------------------------------------------------------------->
<?php
// getting user details from session
if (isset($_SESSION['customer'])) {
$email = $_SESSION['customer'];
$sql = "SELECT * FROM user WHERE user_email = '$email'";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
$user_name = $row['user_name'];
$user_id = $row['user_id'];
$first_name = substr($user_name, 0, strpos($user_name, " "));
}
// getting order details from session
$order_id = $_GET['order_id'];
$sql = "SELECT * FROM orders WHERE order_id = '$order_id' && order_user = '$user_id'";
$result = mysqli_query($conn, $sql);
$rowcount = mysqli_num_rows($result);
if ($rowcount > 0) {
$row = mysqli_fetch_assoc($result);
} else {
echo "<script>alert('Invalid Order Id');</script>";
echo "<script>window.location.href='account.php';</script>";
}
$order_date = $row['order_date'];
$order_status = $row['order_status'];
$order_discount = $row['discount'];
?>
<div class="container mt-5 mb-5">
<div class="row d-flex justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="text-left logo p-2 px-5">
<img src="app\asset\image\logo.svg" width="100" />
</div>
<div class="invoice p-3">
<div class="d-flex justify-content-between">
<div>
<h5>Order Details</h5>
</div>
<div>
<!-- download invoice -->
<a href="invoice.php?orderId=<?php echo $order_id; ?>" class="">Invoice<i class="fas fa-download ms-2"></i></a>
</div>
</div>
<span class="font-weight-bold d-block mt-4">Hello, <?php echo $first_name; ?></span>
<!-- order details -->
<div class="payment border-top mt-3 mb-3 border-bottom table-responsive">
<!-- order details table -->
<table class="table table-borderless">
<tbody>
<tr>
<td>
<div class="py-2">
<span class="d-block text-muted">Order Date</span>
<span><?php echo $order_date; ?></span>
</div>
</td>
<td>
<div class="py-2">
<span class="d-block text-muted">Order No</span>
<span><?php echo $order_id; ?></span>
</div>
</td>
<td>
<div class="py-2">
<span class="d-block text-muted">Payment</span>
<span>Cash On delivery</span>
</div>
</td>
<td>
<div class="py-2">
<span class="d-block text-muted">Order Status</span>
<span><?php echo $order_status; ?></span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- order items -->
<div class="product border-bottom table-responsive">
<table class="table table-borderless">
<tbody>
<?php
$total = 0;
// getting order items from database
$sql = "SELECT * FROM order_p
INNER JOIN product ON product.product_id = order_p.order_item
WHERE order_p.order_id = '$order_id'";
$result = mysqli_query($conn, $sql);
while ($row1 = mysqli_fetch_assoc($result)) {
$product_name = $row1['product_name'];
$product_price = $row1['price'];
$product_img = $row1['product_img'];
$product_qty = $row1['order_qu'];
$product_id = $row1['product_id'];
$product_total = $product_price * $product_qty;
?>
<tr>
<td width="20%">
<img src="<?php echo $product_img; ?>" width="90" />
</td>
<td width="60%">
<span class="font-weight-bold"><?php echo $product_name; ?></span>
<div class="product-qty">
<span class="d-block">Quantity:<?php echo $product_qty; ?> Pcs</span>
</div>
</td>
<td width="20%">
<div class="text-right">
<span class="font-weight-bold">₹ <?php echo $product_price; ?></span>
</div>
</td>
</tr>
<?php
// if order status is delivered then show rating
if ($order_status == "Delivered") {
// checking if user has already rated the product
$sql = "SELECT * FROM review WHERE product_id = '$product_id' AND order_id = '$order_id'";
$result1 = mysqli_query($conn, $sql);
$row_count = mysqli_num_rows($result1);
if ($row_count > 0) {
// if user has already rated the product then show the rating
$row2 = mysqli_fetch_assoc($result1);
$rating = $row2['rating'];
if ($rating == 1) {
echo
"
<tr>
<td colspan='3' class=''>
$rating <i class='fas fa-star text-warning'></i>
</td>
</tr>
";
} elseif ($rating == 2) {
echo
"
<tr>
<td colspan='3' class=''>
$rating <i class='fas fa-star text-warning'></i>
</td>
</tr>
";
} elseif ($rating == 3) {
echo
"
<tr>
<td colspan='3' class=''>
$rating <i class='fas fa-star text-warning'></i>
</td>
</tr>
";
} elseif ($rating == 4) {
echo
"
<tr>
<td colspan='3' class=''>
$rating <i class='fas fa-star text-warning'></i>
</td>
</tr>
";
} elseif ($rating == 5) {
echo
"
<tr>
<td colspan='3' class=''>
$rating <i class='fas fa-star text-warning'></i>
</td>
</tr>
";
}
}
}
$total = $total + $product_total;
}
?>
</tbody>
</table>
</div>
<!-- order total -->
<div class="row d-flex justify-content-end">
<div class="col-md-5">
<table class="table table-borderless">
<tbody class="totals">
<tr>
<td>
<div class="text-left">
<span class="text-muted">Subtotal</span>
</div>
</td>
<td>
<div class="text-right">
<span>₹ <?php echo $total; ?></span>
</div>
</td>
</tr>
<tr>
<td>
<div class="text-left">
<span class="text-muted">Shipping Fee</span>
</div>
</td>
<td>
<div class="text-right">
<span>₹ 0</span>
</div>
</td>
</tr>
<tr>
<td>
<div class="text-left">
<span class="text-muted">Discount</span>
</div>
</td>
<td>
<div class="text-right">
<span class="text-success"><?= $order_discount ?> %</span>
</div>
</td>
</tr>
<tr class="border-top border-bottom">
<td>
<div class="text-left">
<span class="font-weight-bold">Total</span>
</div>
</td>
<td>
<div class="text-right">
<span class="font-weight-bold">₹ <?php echo $total - ($total * $order_discount / 100); ?></span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- order status -->
<p>
We will be sending shipping confirmation email when the item
shipped successfully!
</p>
<p class="font-weight-bold mb-0">Thanks for shopping with us!</p>
<span>Grapple Team</span>
</div>
<div class="d-flex justify-content-between footer p-3">
<span>Need Help? visit our
<a href="contact_us.php"> help center</a></span>
<span>© 2023 Grapple Inc. All rights reserved</span>
</div>
</div>
</div>
</div>
</div>
<!-- Footer --------------------------------------------------------------->
<?php
// include footer.php file
include 'footer.php';
?>
<!-- Footer --------------------------------------------------------------->
<!-- css for showing rating stars -->
<style>
.rating {
float: left;
}
.rate {
float: left;
height: 46px;
padding: 0 10px;
}
.rate:not(:checked)>input {
position: absolute;
top: -9999px;
}
.rate:not(:checked)>label {
float: right;
width: 1em;
overflow: hidden;
white-space: nowrap;
cursor: pointer;
font-size: 30px;
color: #ccc;
}
.rate:not(:checked)>label:before {
content: '★ ';
}
.rate>input:checked~label {
color: #ffc700;
}
.rate:not(:checked)>label:hover,
.rate:not(:checked)>label:hover~label {
color: #deb217;
}
.rate>input:checked+label:hover,
.rate>input:checked+label:hover~label,
.rate>input:checked~label:hover,
.rate>input:checked~label:hover~label,
.rate>label:hover~input:checked~label {
color: #c59b08;
}
</style>
</body>
</html>