-
Notifications
You must be signed in to change notification settings - Fork 1
/
cart.php
292 lines (227 loc) · 13.7 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
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
<?php
session_start();
require "connection.php";
if (isset($_SESSION["u"])) {
$user = $_SESSION["u"]["email"];
$total = 0;
$subtotal = 0;
$shipping = 0;
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cart | mkshop</title>
<link rel="stylesheet" href="bootstrap.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.9.1/font/bootstrap-icons.css">
<link rel="stylesheet" href="style.css" />
<link rel="icon" href="resourses/logo.svg" />
</head>
<body>
<div class="container-fluid">
<div class="row">
<?php
include "header.php";
?>
<div class="col-12 pt-2" style="background-color: #E3E5E4;">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="home.php">Home</a></li>
<li class="breadcrumb-item active" aria-current="page">Cart</li>
</ol>
</nav>
</div>
<div class="col-12 border border-1 border-primary rounded mb-3">
<div class="row">
<div class="col-12">
<label class="form-label fs-1 fw-bold">Cart <i class="bi bi-cart4 fs-1 text-success"></i></label>
</div>
<div class="col-12 col-lg-6">
<hr />
</div>
<div class="col-12">
<div class="row">
<div class="offset-lg-2 col-12 col-lg-6 mb-3">
<input type="text" class="form-control" placeholder="Search in Cart..." />
</div>
<div class="col-12 col-lg-2 mb-3 d-grid">
<button class="btn btn-outline-primary">Search</button>
</div>
</div>
</div>
<div class="col-12">
<hr />
</div>
<?php
$cart_rs = Database::search("SELECT * FROM `cart` WHERE `users_email`='" . $user . "'");
$cart_num = $cart_rs->num_rows;
if ($cart_num == 0) {
?>
<!-- Empty View -->
<div class="col-12">
<div class="row">
<div class="col-12 emptyCart"></div>
<div class="col-12 text-center mb-2">
<label class="form-label fs-1 fw-bold">
You have no items in your Cart yet.
</label>
</div>
<div class="offset-lg-4 col-12 col-lg-4 mb-4 d-grid">
<a href="home.php" class="btn btn-outline-info fs-3 fw-bold">
Start Shopping
</a>
</div>
</div>
</div>
<!-- Empty View -->
<?php
} else {
?>
<!-- products -->
<div class="col-12 col-lg-9">
<div class="row">
<?php
for ($x = 0; $x < $cart_num; $x++) {
$cart_data = $cart_rs->fetch_assoc();
$product_rs = Database::search("SELECT * FROM `product` WHERE
`id`='" . $cart_data["product_id"] . "'");
$product_data = $product_rs->fetch_assoc();
$total = $total + ($product_data["price"] * $cart_data["qty"]);
$address_rs = Database::search("SELECT district.district_id AS `did` FROM
`users_has_address` INNER JOIN `city` ON
users_has_address.city_city_id=city.city_id INNER JOIN `district` ON
city.district_district_id=district.district_id WHERE `users_email`='" . $user . "'");
$address_data = $address_rs->fetch_assoc();
$ship = 0;
if ($address_data["did"] == 15) {
$ship = $product_data["delivery_fee_colombo"];
$shipping = $shipping + $product_data["delivery_fee_colombo"];
} else {
$ship = $product_data["delivery_fee_other"];
$shipping = $shipping + $product_data["delivery_fee_other"];
}
$seller_rs = Database::search("SELECT * FROM `users` WHERE
`email`='" . $product_data["users_email"] . "'");
$seller_data = $seller_rs->fetch_assoc();
$seller = $seller_data["fname"] . " " . $seller_data["lname"];
?>
<div class="card mb-3 mx-0 col-12">
<div class="row g-0">
<div class="col-md-12 mt-3 mb-3">
<div class="row">
<div class="col-12">
<span class="fw-bold text-black-50 fs-5">Seller :</span>
<span class="fw-bold text-black fs-5">John Doe</span>
</div>
</div>
</div>
<hr>
<!-- popup -->
<div class="col-md-4">
<span class="d-inline-block" tabindex="0" data-bs-toggle="popover"
data-bs-trigger="hover focus" data-bs-content="<?php echo $product_data["description"]; ?>"
title="Product Description">
<img src="resourses/empty.svg" class="img-fluid rounded-start" style="max-width: 200px;">
</span>
</div>
<!-- popup -->
<div class="col-md-5">
<div class="card-body">
<h3 class="card-title">Apple iPhone 12</h3>
<span class="fw-bold text-black-50">Colour : black</span> |
<span class="fw-bold text-black-50">Condition : Used</span>
<br>
<span class="fw-bold text-black-50 fs-5">Price :</span>
<span class="fw-bold text-black fs-5">Rs. 100000 .00</span>
<br>
<span class="fw-bold text-black-50 fs-5">Quantity :</span>
<input type="number" class="mt-3 border border-2 border-secondary fs-4 fw-bold px-3 cardqtytext" value="10">
<br><br>
<span class="fw-bold text-black-50 fs-5">Delivery Fee :</span>
<span class="fw-bold text-black fs-5">Rs.250.00</span>
</div>
</div>
<div class="col-md-3">
<div class="card-body d-grid">
<a class="btn btn-outline-success mb-2">Buy Now</a>
<a class="btn btn-outline-danger mb-2"
onclick="removeFromCart(<?php echo $cart_data['cart_id']; ?>);">Remove</a>
</div>
</div>
<hr>
<div class="col-md-12 mt-3 mb-3">
<div class="row">
<div class="col-6 col-md-6">
<span class="fw-bold fs-5 text-black-50">Requested Total <i class="bi bi-info-circle"></i></span>
</div>
<div class="col-6 col-md-6 text-end">
<span class="fw-bold fs-5 text-black-50">Rs.105000.00</span>
</div>
</div>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
<!-- products -->
<!-- summary -->
<div class="col-12 col-lg-3">
<div class="row">
<div class="col-12">
<label class="form-label fs-3 fw-bold">Summary</label>
</div>
<div class="col-12">
<hr />
</div>
<div class="col-6 mb-3">
<span class="fs-6 fw-bold">items (<?php echo $cart_num; ?>)</span>
</div>
<div class="col-6 text-end mb-3">
<span class="fs-6 fw-bold">Rs. <?php echo $total; ?> .00</span>
</div>
<div class="col-6">
<span class="fs-6 fw-bold">Shipping</span>
</div>
<div class="col-6 text-end">
<span class="fs-6 fw-bold">Rs. <?php echo $shipping; ?> .00</span>
</div>
<div class="col-12 mt-3">
<hr />
</div>
<div class="col-6 mt-2">
<span class="fs-4 fw-bold">Total</span>
</div>
<div class="col-6 mt-2 text-end">
<span class="fs-4 fw-bold">Rs. <?php echo $total + $shipping; ?> .00</span>
</div>
<div class="col-12 mt-3 mb-3 d-grid">
<button class="btn btn-primary fs-5 fw-bold">CHECKOUT</button>
</div>
</div>
</div>
<!-- summary -->
<?php
}
?>
</div>
</div>
<?php include "footer.php"; ?>
</div>
</div>
<script src="bootstrap.bundle.js"></script>
<script src="script.js"></script>
<script>
var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
var popoverList = popoverTriggerList.map(function(popoverTriggerEl) {
return new bootstrap.Popover(popoverTriggerEl)
})
</script>
</body>
</html>
<?php
}
?>