This page was made as a personal project in connection with an educational exercise.
This is NOT the official site of the company or brand identified on the page. The creator of this page is NOT affiliated with the company or brand in any way. DO NOT enter any personal information (such as logins, passwords or credit card numbers) on this site.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcart.html
151 lines (117 loc) · 3.59 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
<!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>
#heading{
text-align: center;
color:#fc2779 ;
}
#j_main{
width: 100%;
height: 1000px;
/* border: 1px solid red; */
display: grid;
grid-template-columns: repeat(3,1fr);
grid-template-rows: repeat(10,auto);
gap:20px
}
.box{
/* border: 5px solid green; */
box-shadow: rgba(17, 12, 46, 0.15) 0px 48px 100px 0px;
padding: 5px;
}
img{
width: 300px;
height: 300px;
/* border: 1px solid blue; */
}
.remove{
background-color: #fc2779;
color: white;
border: 0;
padding: 10px 20px 10px 20px;
}
.price{
color: black;
margin-top: -5px;
}
.rating{
margin-top: -20px;
}
.proceed{
background-color: #fc2779;
color: white;
border: 0;
padding: 20px 30px 20px 30px;
margin-left: 200px;
font-weight: bold;
font-size: 15px;
}
</style>
</head>
<body>
<h1 id="heading">My Wishlist</h1>
<h2 id="total"> </h2>
<div id="j_main">
</div>
</body>
</html>
<script>
let sum=0;
let data=JSON.parse(localStorage.getItem("facePrimer")) || []
console.log(data[0])
let container=document.getElementById("j_main")
data.forEach((elem,index)=>{
let box=document.createElement("div");
box.setAttribute("class","box")
let title=document.createElement("h4")
title.innerText=elem.name
let imgBox=document.createElement("div")
imgBox.setAttribute("class","box")
let img=document.createElement("img")
img.src=elem.img1
imgBox.append(img)
let price=document.createElement("h2")
price.setAttribute("class","price")
price.innerText=`Rs ${elem.price}`
let rating=document.createElement("h3")
rating.setAttribute("class","rating")
rating.innerText=`Rating:- ${elem.rating}`
let remove=document.createElement("button")
remove.innerText="Remove"
remove.setAttribute("class","remove")
remove.addEventListener("click",function(){
Remove(elem,index)
})
let proceed=document.createElement("button")
proceed.innerText="proceed to pay ➨"
proceed.setAttribute("class","proceed")
proceed.addEventListener("click",function(){
pro(elem,index)
})
box.append(title,img,price,rating,remove,proceed)
// container.append(title,imgBox,price,rating,remove)
container.append(box)
let total=document.getElementById("total")
total.innerText= `Total:- ${sum=sum+elem.price}`
console.log(total)
})
let Remove=(elem,index)=>{
console.log(elem,index)
data.splice(index,1)
localStorage.setItem("facePrimer",JSON.stringify(data))
window.location.reload()
}
let pay_arr=[]
let pro=(elem,index)=>{
console.log(elem)
pay_arr.push(elem)
console.log(pay_arr)
localStorage.setItem("pay",JSON.stringify(pay_arr))
window.location.href="address.html"
}
</script>