-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcart.html
537 lines (495 loc) · 25.7 KB
/
cart.html
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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
<!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>Furniture</title>
<link rel="stylesheet" href="style.css">
<!-- bootstrap link -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"
integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"
integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>
<!-- bootstrap link -->
<!-- icons -->
<link href='https://unpkg.com/[email protected]/css/boxicons.min.css' rel='stylesheet'>
<!-- icons -->
</head>
<body>
<!-- navbar top -->
<div class="container">
<div class="navbar-top">
<div class="social-link">
<i><img src="./image/twitter.png" alt="" width="30px"></i>
<i><img src="./image/facebook.png" alt="" width="30px"></i>
<i><img src="./image/google-plus.png" alt="" width="30px"></i>
</div>
<div class="logo">
<h3><a href="/index.html" style="color: black;">FURNITURE</a></h3>
</div>
<div class="icons">
<i><img src="./image/search.png" alt="" width="20px"></i>
<i><img src="./image/heart.png" alt="" width="20px"></i>
<a href="cart.html"><i><img src="./image/shopping-cart.png" alt="" width="25px"></i></a>
</div>
</div>
</div>
<!-- navbar top -->
<!-- main content -->
<!-- <div class="main-content shop-content"> -->
<div class=" shop-content">
<nav class="navbar navbar-expand-md" id="navbar-color">
<div class="container">
<!-- Toggler/collapsibe Button -->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span><i><img src="./image/menu.png" alt="" width="30px"></i></span>
</button>
<!-- Navbar links -->
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="home.html">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="shop.html">Shop</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Top Chair</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Chair</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Brands</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#footer">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- <div class="content"> -->
<div class="shop_content">
<h1>Cart Items
</h1>
<!-- <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Repellendus minus modi illum cumque velit
consectetur?</p>
<span id="btn"><button><a href="sign-up.html">Signup</a></button></span>
<span id="btn"><button><a href="login.html">log In</a></button></span>
<span id="btn"><button><a href="login.html">Renovate a Room</a></button></span> -->
</div>
</div>
<!-- main content -->
<!-- card1 -->
<!-- <div class="container">
<h3 class="text-center" style="padding-top: 30px;">SERVICES WE OFFER</h3>
<div class="row" style="margin-top: 50px;">
<div class="col-md-4 py-3 py-md-0">
<div class="card">
<img src="./image/c1.png" alt="" class="card image-top img-fluid" height="200px">
<div class="card-body">
<h5 class="card-titel text-center">Ads</h5>
<p class="text-center">Lorem ipsum dolor sit amet consectetur adipisicing elit. Numquam ipsam
vitae facere eius modi iure possimus, soluta ea inventore. Omnis!</p>
<div id="btn2" class="text-center"><button>View More</button></div>
</div>
</div>
</div>
<div class="col-md-4 py-3 py-md-0">
<div class="card">
<img src="./image/c2.png" alt="" class="card image-top img-fluid" height="200px">
<div class="card-body">
<h5 class="card-titel text-center">3D Renovation</h5>
<p class="text-center">Lorem ipsum dolor sit amet consectetur adipisicing elit. Numquam ipsam
vitae facere eius modi iure possimus, soluta ea inventore. Omnis!</p>
<div id="btn2" class="text-center"><button>View More</button></div>
</div>
</div>
</div>
<div class="col-md-4 py-3 py-md-0">
<div class="card">
<img src="./image/c3.png" alt="" class="card image-top img-fluid" height="200px">
<div class="card-body">
<h5 class="card-titel text-center">Bartering System</h5>
<p class="text-center">Lorem ipsum dolor sit amet consectetur adipisicing elit. Numquam ipsam
vitae facere eius modi iure possimus, soluta ea inventore. Omnis!</p>
<div id="btn2" class="text-center"><button>View More</button></div>
</div>
</div>
</div>
</div>
</div> -->
<!-- card1 -->
<!-- card2 -->
<!-- <div class="container">
<div class="row" style="margin-top: 100px;">
<div class="col-md-4 py-3 py-md-0">
<div class="card" id="tpc">
<img src="./image/ch.png" alt="" class="card image-top img-fluid">
<div class="card-img-overlay">
<h4 class="card-titel">Best Chair</h4>
<p class="card-text">Lorem ipsum dolor.</p>
<div id="btn2"><button>View More</button></div>
</div>
</div>
</div>
<div class="col-md-4 py-3 py-md-0">
<div class="card" id="tpc">
<img src="./image/sf.png" alt="" class="card image-top img-fluid">
<div class="card-img-overlay">
<h4 class="card-titel">Sofa</h4>
<p class="card-text">Lorem ipsum dolor.</p>
<div id="btn2"><button>View More</button></div>
</div>
</div>
</div>
<div class="col-md-4 py-3 py-md-0">
<div class="card" id="tpc">
<img src="./image/work desk.png" alt="" class="card image-top img-fluid">
<div class="card-img-overlay">
<h4 class="card-titel">Work Desk</h4>
<p class="card-text">Lorem ipsum dolor.</p>
<div id="btn2"><button>View More</button></div>
</div>
</div>
</div>
</div>
</div> -->
<!-- card2 -->
<!-- card3 -->
<!-- <div class="container">
<div class="row" style="margin-top: 50px;">
<div class="col-md-3 py-3 py-md-0">
<div class="card" id="c">
<img src="./image/card1.png" alt="" class="card image-top img-fluid">
<div class="card-body">
<h3 class="card-titel text-center">Best Sofa</h3>
<p class="card-text text-center">$1000.50</p>
<div id="btn3"><button>Add to cart</button></div>
</div>
</div>
</div>
<div class="col-md-3 py-3 py-md-0">
<div class="card" id="c">
<img src="./image/card2.png" alt="" class="card image-top img-fluid">
<div class="card-body">
<h3 class="card-titel text-center">Single Sofa</h3>
<p class="card-text text-center">$100.50</p>
<div id="btn3"><button>Add to cart</button></div>
</div>
</div>
</div>
<div class="col-md-3 py-3 py-md-0">
<div class="card" id="c">
<img src="./image/card3.png" alt="" class="card image-top img-fluid">
<div class="card-body">
<h3 class="card-titel text-center">Simple Chair</h3>
<p class="card-text text-center">$300.20</p>
<div id="btn3"><button>Add to cart</button></div>
</div>
</div>
</div>
<div class="col-md-3 py-3 py-md-0">
<div class="card" id="c">
<img src="./image/card4.png" alt="" class="card image-top img-fluid">
<div class="card-body">
<h3 class="card-titel text-center">Modern Chair</h3>
<p class="card-text text-center">$500.50</p>
<div id="btn3"><button>Add to cart</button></div>
</div>
</div>
</div>
</div>
<div class="row" style="margin-top: 50px;">
<div class="col-md-3 py-3 py-md-0">
<div class="card" id="c">
<img src="./image/Dining tables.jpg" alt="" class="card image-top img-fluid">
<div class="card-body">
<h3 class="card-titel text-center">Dining Table</h3>
<p class="card-text text-center">$200.50</p>
<div id="btn3"><button>Add to cart</button></div>
</div>
</div>
</div>
<div class="col-md-3 py-3 py-md-0">
<div class="card" id="c">
<img src="./image/work desk.png" alt="" class="card image-top img-fluid">
<div class="card-body">
<h3 class="card-titel text-center">Work Desk</h3>
<p class="card-text text-center">$100.50</p>
<div id="btn3"><button>Add to cart</button></div>
</div>
</div>
</div>
<div class="col-md-3 py-3 py-md-0">
<div class="card" id="c">
<img src="./image/Bookshelves.jpg" alt="" class="card image-top img-fluid">
<div class="card-body">
<h3 class="card-titel text-center">Book Shelves</h3>
<p class="card-text text-center">$150.50</p>
<div id="btn3"><button>Add to cart</button></div>
</div>
</div>
</div>
<div class="col-md-3 py-3 py-md-0">
<div class="card" id="c">
<img src="./image/bed.jpg" alt="" class="card image-top img-fluid">
<div class="card-body">
<h3 class="card-titel text-center">Bed</h3>
<p class="card-text text-center">$500.60</p>
<div id="btn3"><button>Add to cart</button></div>
</div>
</div>
</div>
</div>
</div> -->
<!-- card3 -->
<!-- about -->
<!-- <div class="container">
<h1 class="text-center" style="margin-top: 50px;">ABOUT</h1>
<div class="row" style="margin-top: 50px;">
<div class="col-md-6 py-3 py-md-0">
<div class="card">
<img src="./image/about.png" alt="">
</div>
</div>
<div class="col-md-6 py-3 py-md-0">
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Laborum, saepe possimus quo, quasi animi
natus nulla beatae neque soluta pariatur id ducimus eum, sed quis enim minima? Fugiat delectus quo
optio nemo voluptatem ullam officiis neque exercitationem tenetur eum corporis quas in esse
blanditiis, quasi animi nam eos! Tempora deleniti eligendi magni ex voluptatum ut dicta nemo et
consequuntur distinctio quae atque porro inventore assumenda, nihil odio iusto accusamus libero
error nam aut, at praesentium cum reiciendis. Possimus consequatur obcaecati at illum in dolores
earum vero ipsum. Ipsam vitae adipisci corrupti totam vel consequuntur fugiat. Perferendis fuga
doloremque tempora, in eos, voluptates iure, optio qui modi ex ea saepe. Eum perspiciatis,
voluptates fugiat nesciunt corrupti minima aliquam repellat, ea quasi natus, recusandae aut nobis
modi. Commodi, alias reiciendis reprehenderit hic soluta consectetur corporis accusantium placeat,
totam minima nostrum magnam dolorum aut dolore, sapiente ea. Magni est quo ipsam nisi iste.</p>
<div id="btn4"><button>Read More...</button></div>
</div>
</div>
</div> -->
<!-- about -->
<!-- add to cart -->
<div class="container my-5">
<div>
<div class="row">
<aside class="col-lg-9">
<div class="card">
<div class="table-responsive">
<table class="table table-borderless table-shopping-cart">
<thead class="text-muted">
<tr class="small text-uppercase">
<th scope="col">Product</th>
<th scope="col" width="120">Quantity</th>
<th scope="col" width="120">Price</th>
</tr>
</thead>
<tbody id="cartContainer">
<!-- <tr>
<td>
<figure class="itemside align-items-center">
<div class="aside"><img src="./image/Bookshelves.jpg" class="img-sm"
style="width:100px">
</div>
<figcaption class="info"> <a href="#" class="title text-dark"
data-abc="true">Book Shelve</a>
</figcaption>
</figure>
</td>
<td> <select class="form-control">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select> </td>
<td>
<div class="price-wrap"> <var class="price">$10.00</var></div>
</td>
<td class="text-right d-none d-md-block"> <a href="" class="btn btn-light"
data-abc="true"> Remove</a> </td>
</tr>
<tr>
<td>
<figure class="itemside align-items-center">
<div class="aside"><img src="./image/work desk.png" class="img-sm"
style="width:100px">
</div>
<figcaption class="info"> <a href="#" class="title text-dark"
data-abc="true">Work Desk</a>
</figcaption>
</figure>
</td>
<td> <select class="form-control">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select> </td>
<td>
<div class="price-wrap"> <var class="price">$15</var> </div>
</td>
<td class="text-right d-none d-md-block"> <a href=""
class="btn btn-light btn-round" data-abc="true"> Remove</a> </td>
</tr>
<tr>
<td>
<figure class="itemside align-items-center">
<div class="aside"><img src="./image/sofa.png" class="img-sm"
style="width:100px">
</div>
<figcaption class="info"> <a href="#" class="title text-dark"
data-abc="true">Latest Sofa</a>
</figcaption>
</figure>
</td>
<td> <select class="form-control">
<option>1</option>
<option>2</option>
<option>3</option>
</select> </td>
<td>
<div class="price-wrap"> <var class="price">$9</var> </div>
</td>
<td class="text-right d-none d-md-block"> <a href=""
class="btn btn-light btn-round" data-abc="true"> Remove</a> </td>
</tr> -->
</tbody>
</table>
</div>
</div>
</aside>
<aside class="col-lg-3">
<!-- <div class="card mb-3">
<div class="card-body">
<form>
<div class="form-group"> <label>Have coupon?</label>
<div class="input-group"> <input type="text" class="form-control coupon" name=""
placeholder="Coupon code"> <span class="input-group-append"> <button
class="btn btn-primary btn-apply coupon">Apply</button> </span> </div>
</div>
</form>
</div>
</div> -->
<div class="card">
<div class="card-body">
<dl class="dlist-align">
<dt>Total price:</dt>
<dd class="text-right ml-3" id="totalCost"></dd>
</dl>
<dl class="dlist-align">
<dt>Discount:</dt>
<dd class="text-right text-danger ml-3">- $10.00</dd>
</dl>
<dl class="dlist-align">
<dt>Total:</dt>
<dd class="text-right text-dark b ml-3"><strong>$59.97</strong></dd>
</dl>
<hr> <a href="#" class="btn btn-out btn-primary btn-square btn-main" data-abc="true"
style="width:100%">
Proceed to checkout
</a> <a href="shop.html" class="btn btn-out btn-success btn-square btn-main mt-2"
style="width:100%" data-abc="true">Continue
Shopping</a>
</div>
</div>
</aside>
</div>
</div>
</div>
<!-- add to cart -->
<!-- footer -->
<footer id="footer">
<h1 class="text-center">Furniture</h1>
<div class="icons text-center">
<i class="bx bxl-twitter"></i>
<i class="bx bxl-facebook"></i>
<i class="bx bxl-google"></i>
<i class="bx bxl-skype"></i>
<i class="bx bxl-instagram"></i>
</div>
<div class="copyright text-center">
© Copyright <strong><span>Furniture</span></strong>. All Rights Reserved
</div>
</footer>
<!-- footer -->
<script>
function getCartItems() {
return JSON.parse(localStorage.getItem('cartItems')) || [];
}
// Function to remove an item from localStorage
function removeItemFromLocalStorage(productName) {
const cartItems = getCartItems();
const updatedCartItems = cartItems.filter(item => item.name !== productName);
localStorage.setItem('cartItems', JSON.stringify(updatedCartItems));
}
// Function to update the total price based on the selected quantity
function updateTotalPrice(element, productPrice) {
const quantity = parseInt(element.value);
const totalPrice = productPrice * quantity;
// Find the corresponding price element and update its value
const priceElement = element.closest('tr').querySelector('.price');
priceElement.textContent = `$${totalPrice.toFixed(2)}`;
}
// Function to display cart items on the page
function displayCartItems() {
const cartItems = getCartItems();
const cartContainer = document.querySelector('#cartContainer');
// Clear previous cart items
cartContainer.innerHTML = '';
// Display each cart item
cartItems.forEach(item => {
const cartItemTr = document.createElement('tr');
cartItemTr.innerHTML = `
<td>
<figure class="itemside align-items-center">
<div class="aside"><img src="${item.image}" class="img-sm" style="width:100px"></div>
<figcaption class="info"> <a href="#" class="title text-dark" data-abc="true">${item.name}</a></figcaption>
</figure>
</td>
<td>
<select class="form-control quantity-select">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</td>
<td>
<div class="price-wrap"> <var class="price">$${(item.price).toFixed(2)}</var></div>
</td>
<td class="text-right d-none d-md-block">
<button class="btn btn-light remove-btn" data-abc="true" data-product="${item.name}">Remove</button>
</td>
`;
const quantitySelect = cartItemTr.querySelector('.quantity-select');
const productPrice = item.price;
// Attach an event listener to the quantity select element
quantitySelect.addEventListener('change', () => {
updateTotalPrice(quantitySelect, productPrice);
});
// Initial update of the total price
updateTotalPrice(quantitySelect, productPrice);
const removeButton = cartItemTr.querySelector('.remove-btn');
removeButton.addEventListener('click', () => {
const productName = removeButton.getAttribute('data-product');
removeItemFromLocalStorage(productName);
displayCartItems(); // Refresh the cart items after removing an item
});
cartContainer.appendChild(cartItemTr);
});
}
// Call the displayCartItems function to initially display the cart items
displayCartItems();
</script>
</body>
</html>