-
Notifications
You must be signed in to change notification settings - Fork 0
/
shopall.js
344 lines (321 loc) · 11.2 KB
/
shopall.js
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
let loginBtn = document.querySelector("#login");
console.log(loginBtn);
let isAuth = localStorage.getItem("isAuth") || "Not Authenticated";
if(isAuth !== "Authenticated"){
window.location.href ="./login.html";
}else{
loginBtn.innerText = "Logout";
loginBtn.addEventListener("click",function(){
localStorage.setItem("isAuth", "Not Authenticated");
window.location.reload();
})
}
let arrData = [
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/0_6326984c-e89a-43ba-b560-e35d40faba70.jpg?v=1703835295&width=250",
title: "PERFUME MINIS FOR ALL (SET OF 4)",
name: "Luxury OUD Experience Set",
rating: 5.0,
price: 849.00,
strikedPrice: 1099.00
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/ManPerfumeGiftSet-01_2_eb660165-6da9-4e14-bdf0-fabd68113a00.jpg?v=1695204946&width=250",
title: "EAU DE PARFUM",
name: "Luxury Perfume Gift Set For Men - 4 x 20mls",
rating: 4.4,
price: 549.00,
strikedPrice: 849.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/OUDGold-01.jpg?v=1698055234&width=250",
title: "EAU DE PARFUM FOR ALL",
name: "OUD GOLD - 100ml",
rating: 5.0,
price: 840.00,
strikedPrice: 1099.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/UnisexPerfumeGiftSet_1.jpg?v=1695204331&width=250",
title: "EAU DE PARFUM",
name: "Luxury Unisex Perfume Gift Set - 4 x 20mls",
rating: 4.6,
price: 549.00,
strikedPrice: 849.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/CEOMAN_3b131d25-7893-4ad5-a17a-4b3de9a3ebd3.jpg?v=1693290059&width=250",
title: "EAU DE PARFUM",
name: "CEO Man Luxury Perfume - 100ml",
rating: 4.9,
price: 489.00,
strikedPrice: 899.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/LuxuryCollectionGiftSet-01.jpg?v=1705048050&width=250",
title: "EAU DE PARFUM",
name: "Luxury Perfume Gift Set For Women - 4 x 20mls",
rating: 4.9,
price: 549.00,
strikedPrice: 849.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/WhiteOUD_b00b288c-016d-4071-b71c-f7e9a2cef50f.jpg?v=1698837551&width=250",
title: "EAU DE PARFUM",
name: "White Oud Unisex - 100ml",
rating: 4.7,
price: 565.00,
strikedPrice: 999.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/Skai_2e0d54be-3ab0-458b-a2af-47d666c93e0e.jpg?v=1693289226&width=250",
title: "EAU DE COLOGNE",
name: "Skai Aquatic Unisex Perfume - 100ml",
rating: 4.9,
price: 489.00,
strikedPrice: 699.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/Fresh_5bfea1d7-05d4-4881-afdd-4516f59ff782.jpg?v=1693290928&width=250",
title: "EAU DE TOILETTE",
name: "Fresh Unisex Perfume - 100ml",
rating: 4.9,
price: 515.00,
strikedPrice: 899.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/OCEANMan.jpg?v=1693289108&width=250",
title: "EAU DE PARFUM FOR MEN",
name: "Ocean Man - 100ml",
rating: 4.9,
price: 840.00,
strikedPrice: 1099.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/HoneyOUD_68b92490-5598-445c-a661-4a2d978e9893.jpg?v=1693289057&width=250",
title: "PARFUM",
name: "Honey Oud Unisex Perfume - 100ml",
rating: 4.6,
price: 575.00,
strikedPrice: 999.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/KLUBMan.jpg?v=1693289090&width=250",
title: "EAU DE PARFUM FOR MEN",
name: "Klub Man - 100ml",
rating: 4.6,
price: 575.00,
strikedPrice: 799.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/SENORITA_239a3020-2072-4cdb-93da-8d2519b69f39.jpg?v=1693289176&width=250",
title: "EAU DE PARFUM",
name: "Senorita Woman Perfume - 100ml",
rating: 4.8,
price: 515.00,
strikedPrice: 899.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/OUDGold-01.jpg?v=1698055234&width=250",
title: "EAU DE PARFUM FOR ALL",
name: "OUD GOLD - 100ml",
rating: 4.9,
price: 840.00,
strikedPrice: 1099.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/HoneyOUD_68b92490-5598-445c-a661-4a2d978e9893.jpg?v=1693289057&width=250",
title: "PARFUM",
name: "Honey Oud Unisex Perfume - 100ml",
rating: 4.6,
price: 575.00,
strikedPrice: 999.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/Skai_2e0d54be-3ab0-458b-a2af-47d666c93e0e.jpg?v=1693289226&width=250",
title: "EAU DE COLOGNE",
name: "Skai Aquatic Unisex Perfume - 100ml",
rating: 4.9,
price: 489.00,
strikedPrice: 699.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/0_3.jpg?v=1698055971&width=250",
title: "EAU DE PARFUM FOR MEN",
name: "SWAG STAR - 100ml",
rating: 4.9,
price: 390.00,
strikedPrice: 499.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/GOAT.jpg?v=1693288981&width=250",
title: "EAU DE PARFUM FOR MEN",
name: "G.O.A.T. Man - 100ml",
rating: 4.8,
price: 575.00,
strikedPrice: 799.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/IMPACT.jpg?v=1693289075&width=250",
title: "EAU DE COLOGNE",
name: "Impact Man Perfume - 100ml",
rating: 4.7,
price: 515.00,
strikedPrice: 899.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/Sin_DonDeoCombo.jpg?v=1693930645&width=250",
title: "UNISEX AND MAN BODY DEODORANTS",
name: "Sin And Don Deo Combo - 2 x 150ml",
rating: 4.4,
price: 299.00,
strikedPrice: 598.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/DEOGiftSetPackof4.jpg?v=1693931505&width=250",
title: "SET OF 4 BODY DEOS FOR MEN",
name: "Deo Gift Set - Stud, Fyre, Fresh And Game Pack Of 4 x 150ml",
rating: 4.2,
price: 499.00,
strikedPrice: 1196.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/Perfume-Trial-Pack-_10-5ml.jpg?v=1693930900&width=250",
title: "PACK OF 10 X 5ML PERFUMES.",
name: "Luxury Perfume Trial Pack",
rating: 4.8,
price: 349.00,
strikedPrice: 399.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/EverreadyWomenCombo.jpg?v=1693931485&width=250",
title: "5 PREMIUM FEMININE SCENTS",
name: "Everready Women Combo",
rating: 4.5,
price: 2249.00,
strikedPrice: 4695.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/RefreshingYouCombo.jpg?v=1693930765&width=250",
title: "FAMILY COMBO",
name: "Refreshing You Combo",
rating: 4.5,
price: 2249.00,
strikedPrice: 4595.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/LoveIsInTheRoll-OnCombo.jpg?v=1693922129&width=250",
title: "ROLL ON DEO - MEN & WOMEN",
name: "Love Is In The Roll-On Combo",
rating: 4.3,
price: 349.00,
strikedPrice: 398.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/DarkOUD-01_1.jpg?v=1698064203&width=250",
title: "EAU DE PARFUM FOR ALL",
name: "Dark OUD - 100ml",
rating: 4.9,
price: 840.00,
strikedPrice: 1099.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/GOAT.jpg?v=1693288981&width=250",
title: "G.O.A.T. Man - 100ml",
name: "EAU DE PARFUM FOR MEN",
rating: 4.8,
price: 575.00,
strikedPrice: 799.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/products/KumkumadiFaceScrubMask-01_508c26a7-953b-4bbb-996f-017852d2032d.jpg?v=1670310597&width=250",
title: "Kumkumadi Face Scrub Mask",
name: "Scrub Mask",
rating: 4.5,
price: 249.00,
strikedPrice: 449.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/Dategiftset-01.jpg?v=1705563221&width=250",
title: "DATE Woman Premium Gift Set",
name: "BATH AND BODY GIFT SET FOR WOMEN",
rating: 5.0,
price: 1329.00,
strikedPrice: 1699.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/FeetLoveFootCream-50gm.jpg?v=1693921603&width=250",
title: "SOOTHING & MOISTURISING FOOT CREAM",
name: "Feet Love Foot Cream - 50gm",
rating: 4.4,
price: 149.00,
strikedPrice: 299.00,
},
];
let container = document.querySelector("#content");
let productNumber = document.querySelector("#productNumber");
productNumber.innerText = `${arrData.length} products`;
function appendData(arrData){
container.innerHTML = "";
arrData.forEach(function(el){
// console.log(el);
let productDiv = document.createElement("div");
let img = document.createElement("img")
img.src=el.imageUrl;
img.style.cursor = "pointer";
img.addEventListener("click",function(){
showProduct(el);
// console.log(el);
})
let p1 = document.createElement("p")
p1.innerText = el.title
let h4 = document.createElement("h4");
h4.innerText = el.name;
h4.setAttribute("class","hide-text")
let ratingDiv = document.createElement("div");
ratingDiv.setAttribute("class","rating")
let ratingP = document.createElement("p");
ratingP.setAttribute("class","material-icons")
ratingP.innerText = "star"
let p2 = document.createElement("p");
p2.innerText = el.rating;
let span1 = document.createElement("span");
span1.innerText = `₹${el.price}`
let span2 = document.createElement("span");
span2.innerText = `₹${el.strikedPrice}`;
span2.style.textDecoration = "line-through";
let btn = document.createElement("button")
btn.innerText = "ADD TO CART";
btn.addEventListener("click",function(){
alert("Added to cart");
addToCart(el);
})
ratingDiv.append(ratingP,p2)
productDiv.append(img,p1,h4,ratingDiv,span1,span2,btn);
container.append(productDiv);
})
}
appendData(arrData)
let select = document.querySelector("#sort");
select.addEventListener("change",function(){
arrData.sort(function(a,b){
if(select.value == "lowToHigh"){
return(a.price - b.price)
}
else if(select.value == "highToLow"){
return(b.price - a.price);
}
})
appendData(arrData);
})
function showProduct(el){
localStorage.setItem("showProduct",JSON.stringify(el));
window.location.href = "./showProduct.html";
}
function addToCart(el){
// console.log(el);
let cartArr = JSON.parse(localStorage.getItem("cartItems")) || [];
cartArr.push(el);
localStorage.setItem("cartItems",JSON.stringify(cartArr));
}
// console.log(newArr)