-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcart_page1.html
216 lines (165 loc) · 5.75 KB
/
cart_page1.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=div, initial-scale=1.0">
<link rel="stylesheet" href="navBar\components\nav.css">
<link rel="icon" href="images/Screenshot 2022-12-14 075742.png" type="image/icon type">
<link rel="stylesheet" href="Slider Module/slider.css">
<script src="Slider Module/slider.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,[email protected],100..700,0..1,-50..200" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.min.css" />
<script src="https://kit.fontawesome.com/24c494a6b6.js" crossorigin="anonymous" ></script>
<title>Document</title>
<style>
#container1{
display: grid;
grid-template-columns: repeat(4,1fr);
grid-template-rows: auto;
gap: 10px;
margin-top: 1%;
}
#container1>div{
box-shadow: rgba(0, 0, 0, 0.07) 0px 1px 1px, rgba(0, 0, 0, 0.07) 0px 2px 2px, rgba(0, 0, 0, 0.07) 0px 4px 4px, rgba(0, 0, 0, 0.07) 0px 8px 8px, rgba(0, 0, 0, 0.07) 0px 16px 16px;
text-align: center;
}
#container1>div:hover{
cursor: pointer;
background-color: rgb(218, 193, 159);
box-shadow: rgba(0, 0, 0, 0.09) 0px 2px 1px, rgba(0, 0, 0, 0.09) 0px 4px 2px, rgba(0, 0, 0, 0.09) 0px 8px 4px, rgba(0, 0, 0, 0.09) 0px 16px 8px, rgba(0, 0, 0, 0.09) 0px 32px 16px;
}
#container1>div>img{
width:70%;
}
#container1>div>img:hover{
width: 75%;
}
button{
width: 150px;
height: 25px;
background-color: rgb(170, 187, 182);
border-radius: 20px;
margin-bottom: 5%;
}
button:hover{
cursor: pointer;
color: rgb(51, 9, 9);
font-weight: bold;
background-color: rgb(57, 79, 121);
}
#totalcost {
display: flex;
justify-content: center;
}
/* #sortprice {
display: flex;
justify-content: center;
}
select {
border: 1px solid white;
} */
/* Medium screens */
@media all and (min-width: 451px) and (max-width: 750px) {
#container1{
grid-template-columns: repeat(2,1fr);
}
}
/* Small screens */
@media all and (min-width: 100px) and (max-width: 450px) {
#container1{
grid-template-columns: repeat(1,1fr);
}
}
</style>
</head>
<body>
<div class="header">
</div>
<div id="totalcost">
<!-- <div> -->
<span> <a style="text-decoration: none; color: red;" href="./page1.html">Back to Cart</a> </span>
<!-- </div>
<div>
<h2 id="total">Your Total cart Price is:- <span id="cart-total">0</span></h2> -->
<!-- </div> -->
</div>
<div id="container1">
</div>
</body>
</html>
<script type="module" >
import { navBar } from "./navBar/components/nav.js";
let header = document.querySelector(".header")
header.innerHTML = navBar();
let items1 = JSON.parse(localStorage.getItem("cartproduct1"));
console.log(items1)
displayTable(items1);
// function displayTable(array){
// console.log(array)
// document.querySelector("#container1").innerHTML="";
// // let count = 0;
// // let total = array.reduce((acc, ele) =>
// // let val = +(ele.price.replace("€",""));
// // acc + ele.val, 0
// // )
// array.forEach((element) => {
// let div=document.createElement("div")
// let img=document.createElement("img")
// img.setAttribute("src",element.image)
// let name=document.createElement("h5")
// name.innerText=element.name;
// let detail=document.createElement("p")
// detail.innerText=element.pro_detail.substring(1,50);
// let id=document.createElement("h4")
// id.innerText=`id: ${element.id}`;
// let price=document.createElement("h4")
// price.innerText=`Price:- ${element.price}`;
// let review=document.createElement("h4")
// review.innerText=`rating: ${element.review_num}`;
// let shiping=document.createElement("p")
// shiping.innerText=`ship: ${element.free_ship}`;
// // let button=document.createElement("button")
// // button.innerText="remove from cart"
// // button.addEventListener("click",function(){
// // my_cart(elem , i)
// // // cartitem.push(element)
// // // localStorage.setItem("cartproduct",JSON.stringify(cartitem))
// // })
// div.append(img,name,detail,id,price,review,shiping)
// document.querySelector("#container1").append(div)
// });
// // localStorage.clear("cartproduct")
// }
// function my_cart(elem, i) {
// items.splice(i, 1)
// displayTable(items)
// localStorage.setItem("cartproduct", JSON.stringify(items))
// }
function displayTable(array){
console.log(array)
document.querySelector("#container1").innerHTML="";
array.forEach((element) => {
let div=document.createElement("div")
let img=document.createElement("img")
img.setAttribute("src",element.image)
// let name=document.createElement("h5")
// name.innerText=element.name;
let detail=document.createElement("p")
detail.innerText=element.pro_title;
let id=document.createElement("h4")
id.innerText=`id: ${element.id}`;
let price=document.createElement("h4")
price.innerText=`Price:- ${element.price}`;
let review=document.createElement("h4")
review.innerText=`rating: ${element.review_num}`;
let shiping=document.createElement("p")
shiping.innerText=`ship: ${element.free_ship}`;
// let shiping=document.createElement("p")
// shiping.innerText=`ship: ${element.free_ship}`;
div.append(img,name,detail,id,price,review,shiping)
document.querySelector("#container1").append(div)
});
// localStorage.clear("cartproduct2")
}
</script>