-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcartpage.html
183 lines (137 loc) · 6.25 KB
/
cartpage.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Ellite Store Cart Page</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<link rel="stylesheet" href="./style/cartpage.css">
</head>
<body class="bg-white">
<div class="Container-Fluid">
<div class="row">
<div class="col-md-10 col-11 mx-auto">
<div class="row mt-5 gx-3">
<!-- left Side div -->
<div id="cart-main" class="col-md-12 col-lg-8 col-11 mx-auto main-cart mb-lg-0 mb-5">
</div>
<!-- rightside div -->
<div class="col-md-12 col-lg-4 col-11 mx-auto mt-lg-0 mt-md-5">
<div class="right_side p-3 shadow bg-white">
<h2 class="product_name mb-5">The Total Amount Of</h2>
<div class="price_indiv d-flex justify-content-between">
<p>Product amount</p>
<p>$<span id="totalcart"></span></p>
</div>
<div class="price_indiv d-flex justify-content-between">
<p>Shipping Charge</p>
<p>$40.0</p>
</div>
<hr/>
<div class="total-amt d-flex justify-content-between font-weight-bold">
<p>The total amount of (including VAT)</p>
<p>$<span id="total_cart_amt"></span></p>
</div>
<a href="Paymentpage.html">
<button class="btn btn-primary text-uppercase">Checkout</button>
</a>
</div>
<!-- discount code part -->
<p>
<button class="btn btn-primary mt-3" type="button" data-bs-toggle="collapse" data-bs-target="#collapseWidthExample" aria-expanded="false" aria-controls="collapseWidthExample">
Apply a discount code(optional)
</button>
</p>
<div style="min-height: 120px;">
<div class="collapse collapse-horizontal" id="collapseWidthExample">
<div class="card card-body" style="width: 300px;">
<input type="text" id="discount_code1" class="form-control font-weight-bold" placeholder="Enter the code"/>
<button class="btn-sm mt-3 btn-dark btn" onclick="discount_code()">Apply</button>
</div>
</div>
</div>
<div class="mt-3 shadow p-3 bg-white">
<div class="pt-4">
<h5 class="mb-4">Expected Delivery Date</h5>
<p>Dec-27th 2022-Dec-30th 2022</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- right side div -->
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"
integrity="sha384-oBqDVmMz9ATKxIep9tiCxS/Z9fNfEXiDAYTujMAeBAsjFuCZSmKbSSUnQlmh/jp3"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"
integrity="sha384-cuYeSxntonz0PPNlHhBs68uyIAVpIIOZZ5JqeqvYYIcEL727kskC66kF92t6Xl2V"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</body>
<script>
let mainCartContainer = document.getElementById("cart-main");
let specificData = JSON.parse(localStorage.getItem("cartProductItem"))||[];
displayData(specificData);
function displayData(primaryData) {
mainCartContainer.innerHTML = null;
let array = primaryData.map((element,index) => {
return `
<div class="Card p-4">
<div class="row">
<div class="col-md-5 col-11 mx-auto bg-light d-flex justify-content-center align-items-center shadow product_img">
<img src=${element.image} alt="cart img" class="img-fluid"/>
</div>
<div class="col-md-7 col-11 mx-auto px-4 mt-2">
<div class="row">
<div class="col-6 card-title">
<h4 class="mb-4 product_name">${element.brand}</h4>
<p class="mb-3">Natural</p>
<p class="mb-3">Cosmetics Product</p>
<p class="mb-4">${element.rating}</p>
</div>
<div class="row">
<div class="col-8 d-flex justify-content-between remove_wish">
<p class="trash" onclick="cartremove(${index},${primaryData})"><i class="fas fa-trash-alt"></i>REMOVE ITEM</p>
<p onclick="movetowhishlist"><i class="fas fa-heart"></i>MOVE TO WISH LIST</p>
</div>
<div class="col-4 d-flex justify-content-end price_money">
<h3>$<span id="itemval">${parseInt(element.price)}</h3>
</div>
</div>
</div>
</div>
</div>
<hr/>
`
})
mainCartContainer.innerHTML = array.join(" ");
}
let totalamount=specificData.reduce((acc,elem)=>acc+elem.price, 0);
document.getElementById("totalcart").innerHTML=totalamount;
let gettingdataTotal=document.getElementById("total_cart_amt");
gettingdataTotal.innerHTML=totalamount+40;
function discount_code(){
let query=document.getElementById("discount_code1");
if(query.value==="mandy"){
document.getElementById("total_cart_amt").innerHTML=(totalamount+40)-40;
alert("Hurray,you got the discount");
}else{
alert("Wrong Coupon Code!!")
}
}
function cartremove(index,primaryData){
console.log(primaryData)
// primaryData.splice(index,1);
primaryData.parentNode.parentNode.removeChild(primaryData.parentNode)
localStorage.setItem("cartProduct",JSON.stringify(primaryData));
displayData(primaryData);
};
</script>
</html>