-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcart.html
169 lines (147 loc) · 8.01 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<!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">
<link rel="stylesheet" href="./index.css">
<link rel="stylesheet" href="./landingPage.css">
<link rel="stylesheet" href="./fragrance.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@8/swiper-bundle.min.css" />
<title>Cart</title>
</head>
<body>
<!-- <div id="navtop">
<a href="./index.html"></a> <div>
<img src="https://cdn02.nnnow.com/web-images/master/navtree_metaData/59b2425ae4b0d70964ee66e0/1505806763887/12NNNOWLOGODESKTOP.png"
alt="logo">
</div></a>
<div><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="bi bi-geo-alt-fill" viewBox="0 0 16 16">
<path d="M8 16s6-5.686 6-10A6 6 0 0 0 2 6c0 4.314 6 10 6 10zm0-7a3 3 0 1 1 0-6 3 3 0 0 1 0 6z" />
</svg> Store Locator
</div>
<div>Get 10% OFF on your first Purchase. Use code BEAUTY10</div>
<div><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="bi bi-google-play" viewBox="0 0 16 16">
<path
d="M14.222 9.374c1.037-.61 1.037-2.137 0-2.748L11.528 5.04 8.32 8l3.207 2.96 2.694-1.586Zm-3.595 2.116L7.583 8.68 1.03 14.73c.201 1.029 1.36 1.61 2.303 1.055l7.294-4.295ZM1 13.396V2.603L6.846 8 1 13.396ZM1.03 1.27l6.553 6.05 3.044-2.81L3.333.215C2.39-.341 1.231.24 1.03 1.27Z" />
</svg> Get App</div>
<div><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box"
viewBox="0 0 16 16">
<path
d="M8.186 1.113a.5.5 0 0 0-.372 0L1.846 3.5 8 5.961 14.154 3.5 8.186 1.113zM15 4.239l-6.5 2.6v7.922l6.5-2.6V4.24zM7.5 14.762V6.838L1 4.239v7.923l6.5 2.6zM7.443.184a1.5 1.5 0 0 1 1.114 0l7.129 2.852A.5.5 0 0 1 16 3.5v8.662a1 1 0 0 1-.629.928l-7.185 2.874a.5.5 0 0 1-.372 0L.63 13.09a1 1 0 0 1-.63-.928V3.5a.5.5 0 0 1 .314-.464L7.443.184z" />
</svg> Track Order</div>
<div><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trophy"
viewBox="0 0 16 16">
<path
d="M2.5.5A.5.5 0 0 1 3 0h10a.5.5 0 0 1 .5.5c0 .538-.012 1.05-.034 1.536a3 3 0 1 1-1.133 5.89c-.79 1.865-1.878 2.777-2.833 3.011v2.173l1.425.356c.194.048.377.135.537.255L13.3 15.1a.5.5 0 0 1-.3.9H3a.5.5 0 0 1-.3-.9l1.838-1.379c.16-.12.343-.207.537-.255L6.5 13.11v-2.173c-.955-.234-2.043-1.146-2.833-3.012a3 3 0 1 1-1.132-5.89A33.076 33.076 0 0 1 2.5.5zm.099 2.54a2 2 0 0 0 .72 3.935c-.333-1.05-.588-2.346-.72-3.935zm10.083 3.935a2 2 0 0 0 .72-3.935c-.133 1.59-.388 2.885-.72 3.935zM3.504 1c.007.517.026 1.006.056 1.469.13 2.028.457 3.546.87 4.667C5.294 9.48 6.484 10 7 10a.5.5 0 0 1 .5.5v2.61a1 1 0 0 1-.757.97l-1.426.356a.5.5 0 0 0-.179.085L4.5 15h7l-.638-.479a.501.501 0 0 0-.18-.085l-1.425-.356a1 1 0 0 1-.757-.97V10.5A.5.5 0 0 1 9 10c.516 0 1.706-.52 2.57-2.864.413-1.12.74-2.64.87-4.667.03-.463.049-.952.056-1.469H3.504z" />
</svg> Loyalty</div>
</div> -->
<div id="navmiddle">
<div>
<input type="text" placeholder="Search" size="35">
</div>
<div>
<a href="./index.html">
<img src="https://cdn07.nnnow.com/web-images/master/navtree_metaData/59b2657be4b0e6b6e16a9180/1548053082431/se.png"
alt="">
</a>
</div>
<div>
<a href="signup.html"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="bi bi-person-circle" viewBox="0 0 16 16">
<path d="M11 6a3 3 0 1 1-6 0 3 3 0 0 1 6 0z" />
<path fill-rule="evenodd"
d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8zm8-7a7 7 0 0 0-5.468 11.37C3.242 11.226 4.805 10 8 10s4.757 1.225 5.468 2.37A7 7 0 0 0 8 1z" />
</svg> LOGIN </a>
<span> | </span>
<a href="" id="bag"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="bi bi-bag-fill" viewBox="0 0 16 16">
<path
d="M8 1a2.5 2.5 0 0 1 2.5 2.5V4h-5v-.5A2.5 2.5 0 0 1 8 1zm3.5 3v-.5a3.5 3.5 0 1 0-7 0V4H1v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V4h-3.5z" />
</svg> Bag</a>
</div>
</div>
<div id="navbottom">
<div> <a href="./brush.html">SALE</a> </div>
<div><a href="./brush.html">MAKE UP</a> </div>
<div> <a href="./brush.html">SKIN CARE</a> </div>
<div id="fragrance">FRAGRANCE</div>
<div><a href="./brush.html">HAIRCARE</a> </div>
<div><a href="./brush.html">TOOLS & BRUSHES</a></div>
<div><a href="./fragrance.html">BRANDS</a> </div>
</div>
<div id="container">
<div>
<form action="">
<select name="" id="byBrand">
<option value="">Select Brand</option>
<option value="">Dior</option>
<option value="">Tom Ford</option>
<option value="">Paco Rebanne</option>
<option value="">D & G</option>
<option value="">DOLCE & GABBANA</option>
<option value="">Kenzo</option>
</select>
<select name="" id="bysize">
<option value="">Choose Size</option>
<option value="">50 ML - 100 ML</option>
<option value="">100 ML - 150 ML</option>
<option value="">150 ML - 175 ML</option>
<option value="">175 ML - 200 ML</option>
</select>
<select name="" id="bycolour">
<option value="">Select Colour</option>
<option value="">No-Colour (498)</option>
<option value="">NA (5)</option>
</select>
<select name="" id="byprice">
<option value=""> By Price</option>
<option value="">High-Low</option>
<option value="">Low-High</option>
</select>
</form>
<h2>Total Items: <span id="bagItems">0</span></h2>
<h2>Your Amount: <span id="amount"></span></h2>
<button id="buy">BUY</button>
</div>
<div id="productlist">
</div>
</body>
</html>
<script>
let count = 0;
let bagItems = JSON.parse(localStorage.getItem("cartItems")) || [];
let total = bagItems.reduce(function (acc, ele) {
return acc + ele.price
}, 0)
document.querySelector("#bagItems").innerHTML = bagItems.length
document.querySelector("#amount").innerText = "Rs " + total
bagItems.forEach(function (ele, i) {
let box = document.createElement("div")
let product_img = document.createElement("img")
let title = document.createElement("h4")
title.innerText = ele.name
let desc = document.createElement("p")
desc.innerText = ele.desc
let price = document.createElement("h3")
price.innerText = "Rs " + ele.price
let addToCart = document.createElement("button")
addToCart.innerText = "REMOVE"
addToCart.addEventListener("click", function () {
// event.target.parentNode.remove()
cartItems = bagItems.splice(i, 1)
localStorage.setItem("cartItems", JSON.stringify(cartItems))
})
product_img.setAttribute("src", ele.image_url)
box.append(product_img, title, desc, price, addToCart)
document.querySelector("#productlist").append(box)
bagItems.push(ele)
localStorage.setItem("productList", JSON.stringify(bagItems))
// bagItems[0].reduce(function (ele) {
// return ele.price
// console.log(ele.price)
// })
})
</script>