-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcart.php
291 lines (251 loc) · 10.3 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>EShopper - Bootstrap Shop Template</title>
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta content="Free HTML Templates" name="keywords">
<meta content="Free HTML Templates" name="description">
<!-- Favicon -->
<link href="img/favicon.ico" rel="icon">
<!-- Google Web Fonts -->
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;700&display=swap" rel="stylesheet">
<!-- Font Awesome -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.0/css/all.min.css" rel="stylesheet">
<!-- Libraries Stylesheet -->
<link href="lib/owlcarousel/assets/owl.carousel.min.css" rel="stylesheet">
<style>
body {
font-family: 'Poppins', sans-serif;
background: #f8f9fa;
color: #333;
}
.breadcrumb {
background-color: transparent;
padding: 0;
margin: 0;
}
.breadcrumb-item a {
color: #6c757d;
text-decoration: none;
}
.breadcrumb-item a:hover {
color: #007bff;
}
.table-responsive {
margin-bottom: 20px;
}
.table th, .table td {
padding: 15px;
vertical-align: middle;
border-color: #ddd;
}
.product-thumbnail img {
max-width: 100px;
height: auto;
margin-right: 15px;
}
.product-name a {
font-family: 'Open Sans', sans-serif;
font-weight: bold;
text-decoration: none;
color: #333;
}
.product-name a:hover {
color: #007bff;
}
.product-quantity input {
width: 60px;
text-align: center;
border: 1px solid #ddd;
border-radius: 5px;
margin: 0 10px;
}
.product-quantity a {
color: #007bff;
text-decoration: none;
}
.product-quantity a:hover {
color: #0056b3;
}
.product-remove i {
color: #dc3545;
font-size: 18px;
cursor: pointer;
}
.product-remove i:hover {
color: #c82333;
}
.card {
margin-bottom: 30px;
border: 1px solid #ddd;
border-radius: 10px;
}
.card-header, .card-body, .card-footer {
padding: 20px;
background: #fff;
border-radius: 10px;
}
.card-footer {
background-color: #f8f8f8;
border-top: 1px solid #ddd;
}
.btn-primary {
background-color: #007bff;
border: none;
transition: background-color 0.3s ease, transform 0.3s ease;
}
.btn-primary:hover {
background-color: #0056b3;
transform: translateY(-2px);
}
.btn-lg {
padding: 15px 20px;
border-radius: 5px;
}
.back-to-top {
position: fixed;
bottom: 30px;
right: 30px;
display: none;
width: 40px;
height: 40px;
text-align: center;
background-color: #007bff;
color: #fff;
border-radius: 50%;
}
.back-to-top i {
line-height: 40px;
}
.back-to-top:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<!-- Topbar Start -->
<?php
include("header.php");
?>
<!-- Topbar End -->
<!-- Navbar Start -->
<?php
include("navbar.php");
?>
<!-- Navbar End -->
<!-- Page Header Start -->
<div class="container-fluid bg-secondary mb-5">
<div class="d-flex flex-column align-items-center justify-content-center" style="min-height: 300px">
<h1 class="font-weight-semi-bold text-uppercase mb-3">Shopping Cart</h1>
<div class="d-inline-flex">
<p class="m-0"><a href="index.php">Home</a></p>
<p class="m-0 px-2">-</p>
<p class="m-0">Shopping Cart</p>
</div>
</div>
</div>
<!-- Page Header End -->
<!-- Cart Start -->
<div class="container-fluid pt-5">
<div class="row px-xl-5">
<div class="col-lg-8 table-responsive mb-5">
<table class="table table-bordered text-center mb-0">
<thead class="bg-secondary text-dark">
<tr>
<th class="product-thumbnail">Products</th>
<th class="product-name">Name of products</th>
<th class="product-price">Price</th>
<th class="product-quantity">Quantity</th>
<th class="product-subtotal">Total</th>
<th class="product-remove">Remove</th>
</tr>
</thead>
<tbody>
<?php
if(isset($_SESSION['cart'])){
foreach($_SESSION['cart'] as $key=>$val){
$productArr=get_product($con,'','',$key);
$pname=$productArr[0]['name'];
$mrp=$productArr[0]['mrp'];
$price=$productArr[0]['price'];
$image=$productArr[0]['image'];
$qty=$val['qty'];
?>
<tr>
<td class="product-thumbnail"><a href="#"><img src="<?php echo './media/product/'.$image?>" alt="<?php echo $pname; ?>"/></a></td>
<td class="product-name"><a href="product.php?id=<?php echo $key; ?>"><?php echo $pname?></a></td>
<td class="product-price">₹<?php echo $price?></td>
<td class="product-quantity">
<input type="number" id="<?php echo $key?>qty" value="<?php echo $qty?>" min="1" max="10"/>
<a href="javascript:void(0)" onclick="manage_cart('<?php echo $key?>','update')">Update</a>
</td>
<td class="product-subtotal">₹<?php echo $qty*$price?></td>
<td class="product-remove"><a href="javascript:void(0)" onclick="manage_cart('<?php echo $key?>','remove')"><i class="fas fa-trash-alt"></i></a></td>
</tr>
<?php } } ?>
</tbody>
</table>
</div>
<div class="col-lg-4">
<div class="card border-secondary mb-5">
<div class="card-header bg-secondary border-0">
<h4 class="font-weight-semi-bold m-0">Cart Summary</h4>
</div>
<div class="card-body">
<div class="d-flex justify-content-between mb-3 pt-1">
<h6 class="font-weight-medium">Subtotal</h6>
<?php
$subtotal=0;
if(isset($_SESSION['cart'])){
foreach($_SESSION['cart'] as $key => $val){
$productArr = get_product($con, '', '', $key);
$price = $productArr[0]['price'];
$qty = $val['qty'];
$subtotal += $price * $qty; // Calculate subtotal
}
}
?>
<h5 class="font-weight-medium">₹<?php echo $subtotal; ?></h5>
</div>
<div class="d-flex justify-content-between">
<h6 class="font-weight-medium">Shipping</h6>
<h6 class="font-weight-medium">₹50</h6>
</div>
</div>
<div class="card-footer border-secondary bg-transparent">
<div class="d-flex justify-content-between mt-2">
<h5 class="font-weight-medium">Total</h5>
<?php
$total = $subtotal + 50; // Calculate total by adding shipping cost
?>
<h5 class="font-weight-medium">₹<?php echo $total; ?></h5> <!-- Display total -->
</div>
<button class="btn btn-lg btn-block btn-primary font-weight-bold my-3 py-3"><a href="checkout.php" class="btn btn-primary">Proceed To Checkout</a></button>
</div>
</div>
</div>
</div>
</div>
<!-- Cart End -->
<!-- Footer Start -->
<?php
include("footer.php");
?>
<!-- Footer End -->
<!-- Back to Top -->
<a href="#" class="btn btn-primary back-to-top"><i class="fa fa-angle-double-up"></i></a>
<!-- JavaScript Libraries -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.bundle.min.js"></script>
<script src="lib/easing/easing.min.js"></script>
<script src="lib/owlcarousel/owl.carousel.min.js"></script>
<!-- Contact Javascript File -->
<script src="mail/jqBootstrapValidation.min.js"></script>
<script src="mail/contact.js"></script>
<!-- Template Javascript -->
<script src="js/main.js"></script>
</body>
</html>