-
Notifications
You must be signed in to change notification settings - Fork 6
/
products.js
84 lines (70 loc) · 3.31 KB
/
products.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
// import { abovefotter } from "../components/abovefotter.js";
// document.getElementById("above_fotter").innerHTML = abovefotter();
import { navbar } from "../components/navbar.js";
document.getElementById("navbar").innerHTML = navbar();
var products = JSON.parse(localStorage.getItem("product"))
var cart = JSON.parse(localStorage.getItem("cart1"))||[];
var box1 = document.createElement("div");
var image = document.createElement("img");
image.src = products.image_url;
box1.append(image);
var box2 = document.createElement("div");
var Proname = document.createElement("h1");
Proname.innerText = products.proName;
var detail = document.createElement("h3");
detail.innerText = products.detail
detail.style.color="grey"
var pri = document.createElement("h3");
pri.innerText = "$" + " "+ products.price;
var strpri = document.createElement("h3");
strpri.setAttribute("id","strikeprice")
strpri.innerText = products.strike;
strpri.style.color="grey"
var offer = document.createElement("h3");
offer.innerText = products.offer;
offer.style.color="lightgreen"
var dis = document.createElement("p");
dis.innerText = "FREE SHIPPING ON ORDERS OVER $99"
dis.style.fontSize="16"
var btn = document.createElement("button");
btn.innerText = "ADD TO CART";
btn.setAttribute("class","btn");
btn.addEventListener("click",function(){
addToCart(products)
})
box2.append(Proname,detail,pri,strpri,offer,dis,btn);
document.getElementById("products").append(box1,box2);
let addToCart = (x)=>{
// console.log(products)
// window.location.href="cart.html";
cart.push(x)
localStorage.setItem("cart1",JSON.stringify(cart));
// console.log(cart);
alert("Item Added To Cart")
}
var like_pro = [{imageUrl:"https://cdn.shopify.com/s/files/1/0248/3473/6191/products/1467633_large.jpg?v=1636498337",
name:"GUCCI GUCCI SANDALS WOMEN PATENT LEATHER BLACK",
price: "$" + 997.00},
{imageUrl:"https://cdn.shopify.com/s/files/1/0248/3473/6191/products/1160253051_RLLZ_2_large.jpg?v=1651156470",
name:"BOTTEGA VENETA BOTTEGA VENETA PADDED CASSETTE LEATHER SHOULDER BAG",
price: "$" + 3079.99},
{imageUrl:"https://cdn.shopify.com/s/files/1/0248/3473/6191/products/WR1409_large.jpg?v=1651391227",
name:"DIORDIOR PILOT SUNGLASSES MONSIEUR 1 XWY1I GOLD/BLACK/HAVANA 63MM",
price: "$" + 495.00},
{imageUrl:"https://cdn.shopify.com/s/files/1/0248/3473/6191/products/1010547627_RLLZ_2_large.jpg?v=1651036108",
name:"KENZO KENZO FELPA LOGO HOODIE",
price: "$" + 218.99},
{imageUrl:"https://cdn.shopify.com/s/files/1/0248/3473/6191/products/75210-75212_b_ORG_zpsfd4prp8u_large.jpg?v=1650449297",
name:"ROMEO GIGLI ROMEO GIGLI C885/35S NERO BLACK LEATHER ADJUSTABLE MENS BELT",
price: "$" + 19.99}]
like_pro.map(({imageUrl,name,price})=>{
var box = document.createElement("div");
var image = document.createElement("img");
image.src = imageUrl;
var dis = document.createElement("p");
dis.innerText = name;
var rate = document.createElement("p");
rate.innerText = price;
box.append(image,dis,rate);
document.getElementById("like_pro").append(box);
})