-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcart.html
602 lines (461 loc) · 16.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
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
<!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>Document</title>
<style>
* {
box-sizing: border-box;
margin: 0px;
}
body {
background-color: aliceblue;
}
#nav>img {
height: 75px;
margin: auto;
}
#nav {
background-color: rgb(230, 63, 63);
display: flex;
justify-content: space-between;
position: sticky;
top: 0;
}
#rightText {
width: 20%;
margin: auto;
margin-top: 5px;
margin-top: 0px;
margin-right: 10px;
text-decoration: none;
color: white;
}
#rightText a {
display: flex;
text-decoration: none;
color: white;
}
#up {
display: flex;
justify-content: space-between;
color: white;
margin-top: 5px;
padding-bottom: 12px;
}
#down {
display: flex;
justify-content: space-between;
color: white;
}
#input {
height: 35px;
width: 450px;
border-radius: 20px;
border-width: 0px;
margin: auto;
margin-bottom: 10px;
padding-left: 15px;
}
body>h1 {
padding: 20px;
color: rgb(98, 98, 98);
}
#cart {
width: 90%;
margin: auto;
}
.card {
display: flex;
justify-content: space-between;
margin-bottom: 20px;
margin-left: 10px;
margin-right: 10px;
background-color: white;
box-shadow: rgba(50, 50, 93, 0.25) 0px 50px 100px -20px, rgba(0, 0, 0, 0.3) 0px 30px 60px -30px, rgba(10, 37, 64, 0.35) 0px -2px 6px 0px inset;
}
#imagediv {
height: 200px;
width: 200px;
}
#imagediv>img {
display: block;
margin: auto;
margin-top: 20px;
height: 60%;
width: 70%;
}
#buttondiv {
display: flex;
justify-content: space-evenly;
margin-top: 10px;
}
#title {
display: block;
margin: auto;
margin-top: 40px;
color: rgb(67, 67, 67);
text-align: center;
padding: 10px;
}
#price1 {
padding-right: 20px;
padding-top: 20px;
text-decoration: line-through;
color: grey;
}
#pricediv {
width: 200px;
}
#pricediv p {
font-size: 8px;
padding-top: 40px;
}
#pricediv>h4 {
padding-top: 10px;
color: rgb(73, 73, 108);
}
#buttondiv button {
border-radius: 5px;
padding: 10px;
border: 0px;
background-color: rgb(86, 86, 86);
color: white;
}
#buttondiv h3 {
font-size: 25px;
color: grey;
}
#price2 {
color: green;
}
#tdiv {
width: 400px;
}
#rwdiv {
display: flex;
justify-content: space-evenly;
}
#rwdiv button {
padding: 20px;
background-color: grey;
border: 0px;
border-radius: 10px;
color: white;
transition: 1s;
}
#rwdiv>button:nth-child(2) {
background-color: rgb(230, 63, 63);
}
#rwdiv button:hover {
box-shadow: rgba(0, 0, 0, 0.25) 0px 54px 55px, rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px, rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px;
transition: 0.5s;
}
#rwdiv>button:nth-child(2):hover {
box-shadow: rgba(201, 20, 20, 0.25) 0px 54px 55px, rgba(201, 20, 20, 0.25) 0px -12px 30px, rgba(201, 20, 20, 0.25) 0px 4px 6px, rgba(201, 20, 20, 0.25) 0px 12px 13px, rgba(201, 20, 20, 0.25) 0px -3px 5px;
}
#checkout {
width: 500px;
background-color: rgb(255, 255, 255);
box-shadow: rgba(50, 50, 93, 0.25) 0px 50px 100px -20px, rgba(0, 0, 0, 0.3) 0px 30px 60px -30px, rgba(10, 37, 64, 0.35) 0px -2px 6px 0px inset;
border-radius: 10px;
}
#page {
display: flex;
}
#checkout>button {
width: 100%;
color: white;
background-color: rgb(230, 63, 63);
padding: 10px;
border: 0px;
transition: 0.5s;
border-top-right-radius: 10px;
border-top-left-radius: 10px;
}
#checkout>button:hover {
background-color: rgb(161, 17, 17);
transition: 0.5s;
}
#pbox {
width: 80%;
margin-top: 30px;
display: flex;
justify-content: space-between;
margin: auto;
margin-top: 20px;
}
#pbox input {
width: 100%;
padding: 10px;
text-align: center;
background-color: rgb(242, 242, 242);
border: 0px;
}
#pbox button {
background-color: rgb(243, 243, 243);
color: rgb(1, 1, 201);
border: 0px;
}
#pbox button:hover {
background-color: rgb(190, 190, 190);
}
#totaldiv {
padding-top: 100px;
text-align: center;
color: grey;
margin-bottom: 20px;
}
#totaldiv h4 {
font-size: 10px;
margin: 10px;
}
#footer {
margin-top: 400px;
display: flex;
justify-content: space-evenly;
color: white;
background-color: rgb(1, 1, 201);
padding-top: 10px;
padding-bottom: 10px;
}
#footer ul{
list-style: none;
}
#footer li{
margin-top: 10px;
}
body>h4{
background-color: rgb(0, 0, 191);
color: white;
text-align: center;
padding-top: 10px;
padding-bottom: 20px;
font-size: smaller;
}
</style>
</head>
<body>
<div id="nav">
<img class="logo" src="./Images/Reliance-Digital-Logo-Vector-File.webp.jpg">
<input type="text" class="search" placeholder="Find your favourite products" id="input">
<div id="rightText">
<div id="up">
<a href="">Find a store</a>
<p>|</p>
<a href="">Buying guide</a>
<p>|</p>
<a href="">Contact us </a>
</div>
<div id="down">
<a href="">Select Pin Code</a>
<p>|</p>
<a href="Index.html"> Home </a>
<p>|</p>
<a href="">Login </a>
</div>
</div>
</div>
<h1 id="MyCart">My Cart</h1>
<div id="page">
<div id="cart">
</div>
<div id="checkout">
<button>CHECKOUT</button>
<div id="pbox">
<input type="text" placeholder="COUPON CODE">
<button>Apply</button>
</div>
<div id="totaldiv">
<div id="billitems"></div>
<h3 id="Dcharges">Delivery charges : 100$</h3>
<hr>
<h2 id="totalp"></h2>
</div>
</div>
</div>
<div id="footer">
<div class="product-categories">
<ul>
<li>Product Categories</li>
<li>Smartphones</li>
<li>Laptops</li>
<li>DSLR Cameras</li>
<li>Televisions</li>
<li>Air Conditioners</li>
<li>Refrigerators</li>
<li>Kitchen Appliances</li>
<li>Accessories</li>
<li>Personal Care & Grooming</li>
</ul>
</div>
<div class="site-info">
<ul>
<li>Site Info</li>
<li>About Reliance Digital</li>
<li>resQ Services</li>
<li>Site Map</li>
<li>Gift Cards</li>
<li>Corporate Enquiries</li>
<li>Contact Us</li>
</ul>
</div>
<div class="resource-center">
<ul>
<li>Resource center</li>
<li>Product Reviews</li>
<li>Buying Guides</li>
<li>How Tos</li>
<li>Featured Stories</li>
<li>Events & Happenings</li>
<li>Nearest Store</li>
</ul>
</div>
<div class="policies">
<ul>
<li>Policies</li>
<li>Terms of Use</li>
<li>FAQs</li>
<li>Cancellation and Return Policy</li>
<li>Pricing and Payments Policy</li>
<li>Shipping and Delivery Policy</li>
<li>Privacy Policy</li>
<li>E-waste Recycling Policy</li>
<li>EMI and Additional Cashback T&C</li>
<li>RelianceOne Loyalty Program T&C</li>
<li>Caution Notice</li>
</ul>
</div>
</div>
<h4>Disclaimer <br>Product prices, offers and availability are subject to change from time to time. All prices are inclusive of taxes. Product colours & images are only for illustration and they may not exactly match with the actual product. Product specs are subject to change & may vary from actual product. While every care is taken to avoid inaccuracies in content, these are provided as is, without warranty of any kind.</h4>
</body>
<script>
let Dcharges = document.getElementById("Dcharges")
let MyCart = document.getElementById("MyCart")
let cart = document.getElementById("cart")
let totalp = document.getElementById("totalp")
let cartdata = localStorage.getItem("cartdata")
let billitems = document.getElementById("billitems")
if (cartdata === null) {
cartdata = []
} else {
cartdata = JSON.parse(cartdata)
}
// //Displaying Images
function disc_disp(data) {
for (let i = 0; i < data.length; i++) {
let titlediv = document.createElement("div")
let rcart = document.createElement("button")
let wish = document.createElement("button")
let rwdiv = document.createElement("div")
let pricediv = document.createElement("div")
let card = document.createElement("div")
let imagediv = document.createElement("div")
let image = document.createElement("img")
let buttondiv = document.createElement("div")
let buttonLeft = document.createElement("button")
let quantity = document.createElement("h3")
let buttonRight = document.createElement("button")
let price1 = document.createElement("h4")
let title = document.createElement("h3")
let price2 = document.createElement("h3")
let desc = document.createElement("p")
let ysave = document.createElement("h4")
let totalp = document.createElement("h2")
let bill = document.createElement("h4")
rcart.setAttribute("id", "rcart")
rwdiv.setAttribute("id", "rwdiv")
titlediv.setAttribute("id", "tdiv")
price2.setAttribute("id", "price2")
title.setAttribute("id", "title")
price1.setAttribute("id", "price1")
buttondiv.setAttribute("id", "buttondiv")
card.setAttribute("class", "card")
imagediv.setAttribute("id", "imagediv")
buttonLeft.setAttribute("id", "buttonLeft")
quantity.setAttribute("id", "quantity")
buttonRight.setAttribute("id", "buttonRight")
pricediv.setAttribute("id", "pricediv")
desc.innerText = "*Delivery assurance is subject to our delivery locations staying open as per govt. regulations"
price1.innerText = "MRP " + data[i].price * data[i].quantity + "$"
image.setAttribute("src", data[i].image)
buttonLeft.innerText = "<"
buttonRight.innerText = ">"
quantity.innerText = data[i].quantity
title.innerText = data[i].title
let p = 0
p = data[i].price * (1 - (data[i].discounts / 100))
p = Math.floor((p) * data[i].quantity)
totalp.innerText = Number(totalp.innerText) + p
price2.innerText = "MRP " + p + "$"
ysave.innerText = "You save: " + Math.floor((data[i].price * data[i].quantity) - p) + "$"
wish.innerText = "Add to Wishlist"
rcart.innerText = "Remove from Cart"
bill.innerText = data[i].title + " : " + price2.innerText
buttonLeft.addEventListener("click", () => {
quantity.innerText = Number(quantity.innerText) - 1
data[i].quantity--
localStorage.setItem("cartdata", JSON.stringify(cartdata))
price1.innerText = "MRP " + Math.floor(data[i].price * data[i].quantity) + "$"
p = data[i].price * (1 - (data[i].discounts / 100))
p = Math.floor(p) * data[i].quantity
price2.innerText = "MRP" + p + "$"
if (data[i].quantity < 1) {
cartdata = cartdata.filter((element) => {
if (element.id == data[i].id) { return false } else { return true }
})
localStorage.setItem("cartdata", JSON.stringify(cartdata))
card.innerHTML = ""
}
})
buttonRight.addEventListener("click", () => {
quantity.innerText = Number(quantity.innerText) + 1
data[i].quantity++
localStorage.setItem("cartdata", JSON.stringify(cartdata))
price1.innerText = "MRP " + Math.floor(data[i].price * data[i].quantity) + "$"
p = data[i].price * (1 - (data[i].discounts / 100))
p = Math.floor((p) * data[i].quantity)
price2.innerText = "MRP" + p + "$"
})
rcart.addEventListener("click", () => {
cartdata = cartdata.filter((element) => {
if (element.id == data[i].id) { return false } else { return true }
})
localStorage.setItem("cartdata", JSON.stringify(cartdata))
card.innerHTML = ""
})
billitems.append(bill)
buttondiv.append(buttonLeft, quantity, buttonRight)
imagediv.append(image, buttondiv)
pricediv.append(price1, price2, ysave, desc)
rwdiv.append(wish, rcart)
titlediv.append(title, rwdiv)
card.append(imagediv, titlediv, pricediv)
cart.append(card)
}
}
disc_disp(cartdata)
let sum = 0
for (let i = 0; i < cartdata.length; i++) {
sum = sum + cartdata[i].quantity * (cartdata[i].price * (1 - (cartdata[i].discounts / 100)))
}
if (sum != 0) {
totalp.innerText = "Total Price to pay : " + Math.floor(Number(sum) + 100) + "$"
}
else {
totalp.innerText = ""
}
if (cartdata.length == 0) {
MyCart.innerText = "You have no Items in your cart"
Dcharges.innerText = ""
}
const input = document.getElementById("input");
input.addEventListener("click", () => {
window.location.href = "Products.html";
});
</script>
</html>
<!-- Issue when I press on remove from cart I need to manually reload it
Issue when I add Items that are not in the cart from the home page the quantity for all becomes 0 -->