forked from uzairansari11/Apna-E-Cart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cart.html
508 lines (398 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
<!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>Apna E-store | cart</title>
<link rel="icon" type="image/x-icon" href="image\logoFooter.jpg">
<link rel="stylesheet" href="navBar&footer.css">
<link rel="stylesheet" href="slider.css">
<style>
* {
font-family: Roboto, "system-ui", sans-serif;
}
/* ------------------Navigation bar start -------------------*/
#cont {
width: 100%;
display: flex;
justify-content: space-evenly;
margin-top: 30px;
}
#cl {
width: 60%;
/* border: 1px solid red; */
}
#cr {
width: 26%;
}
#checkout {
width: 100%;
background-color: #e42529;
height: 40px;
border: 0px;
border-radius: 3px;
color: white;
font-size: larger;
font-weight: bold;
}
#checkout:hover {
cursor: pointer;
background-color: #003380;
}
#crbody {
box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
height: 300px;
width: 95%;
margin-top: 15px;
padding-left: 10px;
padding-right: 10px;
padding-top: 10px;
}
#crbody>div {
height: 17%;
width: 100%;
margin-top: 5px;
}
#input {
width: 250px;
height: 30px;
border: 1px solid rgb(93, 146, 239);
border-radius: 4px;
color: rgb(93, 146, 239);
}
#check {
width: 100px;
height: 34px;
background-color: white;
border: 1px solid rgb(93, 146, 239);
font-weight: bold;
color: rgb(93, 146, 239);
border-radius: 4px;
}
#check:hover {
background-color: rgb(93, 146, 239);
color: white;
cursor: pointer;
}
.p {
display: flex;
justify-content: space-between;
}
.pp {
font-weight: bold;
display: flex;
justify-content: space-between;
}
#cl>div {
/* border: 1px solid red; */
height: 230px;
width: 100%;
display: flex;
justify-content: space-between;
margin-top: 30px;
box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
padding-right: 30px;
}
#cl>div>div:nth-child(1) {
/* border: 1px solid black; */
width: 18%;
}
#cl>div>div:nth-child(2) {
/* border: 1px solid black; */
width: 46%;
}
#cl>div>div:nth-child(3) {
/* border: 1px solid black; */
width: 30%;
text-align: right;
}
#cl>div>div:nth-child(1)>img {
width: 100%;
margin-top: 35px;
}
#cl>div>div:nth-child(1)>img:hover {
cursor: pointer;
}
#cl>div>div:nth-child(2)>button:hover {
cursor: pointer;
background-color: #003380;
border: 0px;
}
#cl>div>div:nth-child(2)>input {
width: 30px;
}
#cl>div>div:nth-child(2)>h3:hover {
cursor: pointer;
}
#line {
border-bottom: 1px solid gray;
width: 100%;
height: 25px;
/* font-size: smaller; */
}
</style>
</head>
<body>
<!-- navbar start -->
<body id="top">
<div id="container">
<div class="nav">
<div id="logo"> <a href="index.html"> <img src="image\logo.jpg" alt=""></a></div>
<div id="searchBar">
<form>
<input type="text" id="searchInput" placeholder="Find your favorite products" name="search" />
<button type="submit" class="submit">Search</button>
</form>
</div>
<div class="restOption">
<div>
<a href="#"> <img src="image\map.png" alt="location">Find a store</a>
<a href="buyingGuides.html">Buying guides</a>
<a href="#footer">Contact us</a>
</div>
<div>
<a href="#">Select your PIN Code</a>
<a href="cart.html">
<div></div><img src="image\cart.png" alt="cart">Cart
</a>
<a href="login.html" id="user_name"><img src="image\account.png" alt="user">Login</a>
<button id="logout_btn" style="display: none" >Logout</button>
</div>
</div>
</div>
<!-- Nav End -->
<div id="line"></div>
<div id="cont">
<div id="cl"></div>
<div id="cr">
<button id="checkout" onclick="ch()">CHECKOUT</button>
<div id="crbody">
<div>
<input type="text" placeholder="COUPON CODE" id="input">
<button id="check" onclick="coupon()">check </button>
<hr>
</div>
<p class="pp" id="pd">PRICE DETAILS</p>
<Div class="p">
<p>price</p>
<p class="price"></p>
</Div>
<Div class="p">
<p>Delivery Charges</p>
<p>FREE</p>
</Div>
<hr>
<Div class="pp">
<p>AMOUNT PAYABLE</p>
<p id="rice"></p>
</Div>
</div>
</div>
</div>
<!-- footer start -->
<footer>
<div>
<div id="footer">
<div>
<ul>PRODUCT CATAGORIES
<li><a href="#">Smartphones</a></li>
<li><a href="#">Laptops</a></li>
<li><a href="#">DSLR Cameras</a></li>
<li><a href="#">Televisions</a></li>
<li><a href="#">Air conditioners</a></li>
<li><a href="#">Refrigerators</a></li>
<li><a href="#">Kitchen Appliances</a></li>
<li><a href="#">Accessories</a></li>
<li><a href="#">Personal Care & Grooming</a></li>
</ul>
</div>
<div>
<ul>SITE INFO
<li><a href="#">About Reliance Digital</a></li>
<li><a href="#">resQ Services</a></li>
<li><a href="#">Site Map</a></li>
<li><a href="#">Gift Cards</a></li>
<li><a href="#">Corporate Enquires</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
</div>
<div>
<ul>RESOURCE CENTER
<li><a href="#">Product Reviews</a></li>
<li><a href="#">Buying Guides</a></li>
<li><a href="#">How Tos</a></li>
<li><a href="#">Featured Stories</a></li>
<li><a href="#">Event & Happenings</a></li>
</ul>
</div>
<div>
<ul>POLICIES
<li><a href="#">Terms of use</a></li>
<li><a href="#">Cancellation and Retruns</a></li>
<li><a href="#">Privacy Policy</a></li>
<li><a href="#">E-waste Policy</a></li>
<li><a href="#">EMI Terms and Conditions</a></li>
<li><a href="#">Pricing and Payments Policy</a></li>
<li><a href="#">Delivery & Shipping Policy</a></li>
<li><a href="#">Apna E-Store Maha Cashback T&C</a></li>
</ul>
</div>
</div>
<div id="footerSocial">
<div>
<h4>FOLLOW US</h4>
<a href="#"><img
src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTE8IpEU3sOxQxNjMw3VAoSWsekRpvgOvjziQ&usqp=CAU"
alt="" class="socialmedialogo"></a>
<a href="#"><img
src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTQuQ1WZVJ3GUDCgjBkdoi29hZKhG2jqSJm2A&usqp=CAU"
alt="" class="socialmedialogo"></a>
<a href="#"><img
src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS49-2NdYCnhN07iUFqsG_ExFiP3QjH9s9naA&usqp=CAU"
alt="" class="socialmedialogo"></a>
</div>
<div>
<h4>EXPERIENCE RELIANCE DIGITAL APP ON MOBILE</h4>
<img src="https://www.reliancedigital.in/build/client/images/google_play_store.png" alt=""
class="image-icon">
<img src="https://www.reliancedigital.in/build/client/images/ios_app_store_icon.png" alt=""
class="image-icon">
</div>
<div>
<img src="" alt="">
</div>
<div id="footorlogo">
<a href="#top"> <img src="image\logoFooter.jpg" alt="logo"></a>
</div>
</div>
</div>
<div id="bottom">
<p>Disclaimer</p>
<p>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.</p>
<hr>
<p> © 2022 Reliance Digital. All Rights Reserved.</p>
</div>
</footer>
</body>
</html>
<script>
let data = JSON.parse(localStorage.getItem("apan_e-store_cartproduct"));
let total = data.reduce(function (acc, ele) {
return acc + Number(ele.price);
}, 0);
document.querySelector("#rice").innerText = "₹" + total;
document.querySelector(".price").innerText = "₹" + total;
display(data);
function display(data) {
console.log(data);
for (let i = 0; i < data.length; i++) {
let d = document.createElement("div");
let d1 = document.createElement("div");
let img = document.createElement("img");
img.src = data[i].avatar;
d1.append(img);
d1.style.hover
d1.addEventListener("click", function () {
localStorage.setItem("product_details", JSON.stringify(data[i]))
window.location.href = "product.html"
});
let d2 = document.createElement("div");
let h3 = document.createElement("h3");
h3.innerText = data[i].title;
let p1 = document.createElement("p");
let aa = Math.floor(Math.random() * 1234567) + 123456;
p1.innerText = "Product Id: " + aa;
p1.style.fontWeight = "bold";
p1.style.color = "grey";
let count = 1;
let b1 = document.createElement("button");
b1.innerText = "-";
let inp = document.createElement("input");
inp.style.textAlign = "center";
inp.value = count;
let b2 = document.createElement("button");
b2.innerText = "+";
let pri = data[i].price;
let h2 = document.createElement("h2");
h2.innerText = "₹" + pri;
let p2 = document.createElement("p");
p2.innerText = "MRP ₹" + (Number(data[i].price) + 100);
b1.addEventListener("click", function () {
if (count > 1) {
count--;
inp.value = count;
pri = Number(data[i].price) * count;
h2.innerText = "₹" + pri;
p2.innerText = "MRP ₹" + (Number(data[i].price) + 100) * count;
total = total - Number(data[i].price);
document.querySelector("#rice").innerText = "₹" + total;
document.querySelector(".price").innerText = "₹" + total;
}
})
b2.addEventListener("click", function () {
count++;
inp.value = count;
h2.innerText = "₹" + Number(data[i].price) * count;
p2.innerText = "MRP ₹" + (Number(data[i].price) + 100) * count;
total = total + Number(data[i].price);
console.log(total);
document.querySelector("#rice").innerText = "₹" + total;
document.querySelector(".price").innerText = "₹" + total;
})
d2.append(h3, p1, b1, inp, b2);
let d3 = document.createElement("div");
h2.style.color = "#003380";
p2.style.textDecoration = "line-through"
let p4 = document.createElement("p");
p4.innerText = "Free Shipping";
p4.style.color = "#008000";
p4.style.fontWeight = "bold";
let p5 = document.createElement("p");
p5.innerText = "*Delivery assurance is subject to our delivery locations staying open as per govt. regulations";
p5.style.fontSize = "small";
d3.append(h2, p2, p4, p5);
d.append(d1, d2, d3);
document.querySelector("#cl").append(d);
h3.addEventListener("click", function () {
localStorage.setItem("product_details", JSON.stringify(data[i]))
window.location.href = "product.html"
});
}
}
function coupon() {
let coupon_code = document.querySelector("#input").value;
console.log(coupon_code);
if(coupon_code==="MASAI0724"){
alert("50% COUPON ADD SUCCESSFULLY");
document.querySelector("#input").value = "";
}else{
alert("INVALID COUPON ");
}
}
document.querySelector("#line").innerText = "APNA E-STORE: Home > Products > Cart";
function ch() {
let am = document.querySelector("#rice").innerText;
localStorage.setItem("amount", am);
window.location.href = "payment.html";
}
let user_login = localStorage.getItem("user_login") || false;
if (user_login) {
let a = localStorage.getItem("fName")||localStorage.getItem("againName");
document.querySelector("#user_name").innerText = "Hi, " + a;
document.getElementById("logout_btn").style.display="flex"
}
let user_logout = document.getElementById("logout_btn");
user_logout.addEventListener("click",()=>{
localStorage.removeItem("user_login");
localStorage.removeItem("fName");
document.querySelector("#user_name").innerText = localStorage.getItem("loginIcon");
document.getElementById("logout_btn").style.display="none"
document.querySelector("#user_name").innerHTML = `<img src="./image/account.png"}>Login`
window.location.href="index.html"
});
</script>