-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcart.html
executable file
·146 lines (120 loc) · 3.69 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
<!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>
#item{
width: 70%;
display: flex;
border: 1px solid transparent;
justify-content: space-between;
margin: auto;
padding:1% 3%;
margin-top: 1%;
}
#qpp , #qp{
width:30%;
display: flex;
justify-content: space-between;
/* padding: 2%; */
}
#small-img{
height: 120px;
width:70%;
border: 1px solid transparent;
display: flex;
justify-content: space-between;
margin: auto;
}
#qty{
height:30px;
width: 50px;
}
.checkoutButton{
padding:12px 100px;
margin-top:5px;
text-align: center;
background-color: black;
color:white;
border: none;
}
.checkoutButtondiv{
margin:auto;
border:1px transparent;
margin-left:44%;
}
</style>
</head>
<body>
<div class="checkoutButtondiv">
<a href="payment.html">
<button class="checkoutButton">CHECKOUT</button>
</a>
</div>
<div id="item">
<div>ITEM</div>
<div>DESCRIPTION</div>
<div id="qp">
<div>TOTAL QUANTITY</div>
<div>PRICE</div>
</div>
</div>
<hr width="70%" />
<!-- <div id="small-img">
<img height="120px" width="80px" src="https://cdn.shopify.com/s/files/1/0293/9277/products/10-29-21Studio2_ME_DJ_11-37-23_39_ED1064N_Black_4857_PB_468x.jpg?v=1635970306"/>
<div id="qpp">
<input id="qty" />
<p>--------</p>
</div>
</div>
<hr width="70%" /> -->
</body>
</html>
<script>
var shoppingBag = JSON.parse(localStorage.getItem("shoppingBag"))||[];
console.log(shoppingBag);
displayShoppingBag(shoppingBag);
function displayShoppingBag(shoppingBag) {
var sum = 0;
var qty = 0;
// for (var i = 0; i < shoppingBag.length; i++) {
// sum += +shoppingBag[i].price.slice(1);
// }
// console.log(sum);
shoppingBag.map(function(elem ,index){
var div = document.createElement("div");
var img = document.createElement("img");
var name = document.createElement("p");
name.textContent=elem.a;
var inner_div = document.createElement("div");
var input = document.createElement("input");
var p = document.createElement("p");
var hr = document.createElement("hr");
div.setAttribute("id" , "small-img");
input.setAttribute("id" , "qty");
inner_div.setAttribute("id" , "qpp");
img.setAttribute("src" , elem.image)
img.setAttribute("height","120px");
img.setAttribute("width","100px")
input.value= ++qty;
p.textContent= +(elem.subdiv2) ;
hr.setAttribute("width" , "70%")
inner_div.append(input , p);
div.append(img ,name, inner_div );
document.querySelector("body").append(div,hr);
document.querySelector("#qty").textContent = +(elem.subdiv1) + +(elem.subdiv1);
document.querySelector("#qty").textContent = shoppingBag.length;
// document.querySelector("#promo").addEventListener("click" , function(){
// var promo = document.querySelector("input").value;
// if(promo == "masai30")
// {
// sum = sum - sum/3;
// document.querySelector("#cost").textContent = sum;
// }
// });
})
}
</script>