-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkout.html
183 lines (161 loc) · 5.89 KB
/
checkout.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 http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=", initial-scale=1.0>
<link rel="stylesheet" href="./styles/checkout.css">
<link rel="stylesheet" href="./styles/main.css">
<title>Document</title>
</head>
<body>
<div id="nav_container"></div>
<div id="checkout_main">
<div id="checkout_scroll">
<div id="order_summary_div">
<div id="order_btn" role="button">
<div id="order_txt">
<div id="order_1">
<p>1</p>
</div>
<div id="order_char">
<p>Order Summary</p>
</div>
</div>
<div id="order_arrow">
</div>
</div>
<div id="order_append">
</div>
</div>
<!--<div id="order_show" style="border: 1px solid red">
<div id="order_append">
</div>
</div>-->
<div id="address_div">
<div id="aaddress_btn" role="button">
<div id="address_txt">
<div id="address_1">
<p>2</p>
</div>
<div id="address_char">
<p>Address</p>
</div>
</div>
<div id="address_arrow">
</div>
</div>
<div id="address_main">
<div>
<input class="address_css" type="text" placeholder="Address" style="color: grey;">
</div>
<div>
<input class="address_css" type="text" placeholder="Pincode" style="color: grey;">
</div>
<div id="address_flex">
<div>
<input class="address_css" type="text" placeholder="City">
</div>
<div>
<input class="address_css" type="text" placeholder="State">
</div>
</div>
</div>
</div>
<div id="payment_div">
<div id="payment_btn" role="button">
<div id="payment_txt">
<div id="payment_1">
<p>3</p>
</div>
<div id="payment_char">
<button onclick="window.location.href='payment.html'"><p>Proceed to pay</p></button>
</div>
</div>
<div id="payment_arrow">
</div>
</div>
</div>
</div>
<div id="checkout_fixed">
<div id="discount">
<div>
<p>Apply Discount</p>
</div>
<div id="discount_div">
<div>
<div class="check_btn">
<input class="check_coupon" type="text">
<button id="chk_btn">Apply</button>
</div>
<div class="check_main">
<p class="check_char" style="color: #379f8e;">Coupon Discount:</p>
<p class="check_disc" style="color :#379f8e; ">- ₹0</p>
</div>
<hr>
<div class="check_mainp">
<p style="color: #379f8e">Total:</p>
<p class="check_total" style="color: #379f8e"></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div style="padding: 150px;"></div>
<div class="footer" id="foot_cont"></div>
</body>
</html>
<script type="module">
import {navbar, footer} from "./components/navbar.js";
let navbar_div = document.getElementById("nav_container");
navbar_div.innerHTML = navbar();
let footer_content = document.getElementById("foot_cont");
footer_content.innerHTML = footer();
let arr = JSON.parse(localStorage.getItem("cart_data")) || []
arr.map(function (el) {
let div = document.createElement("div")
div.style.display="flex"
div.style.height="50px"
div.style.width="400px"
div.style.justifyContent="space-between"
let p1 = document.createElement("p")
p1.textContent=el.heading;
p1.style.marginLeft="10px"
let p2 = document.createElement("p")
p2.textContent=el.price;
p2.style.marginRight="20px"
p2.style.fontWeight="900"
p2.style.color="rgb(235,150,51)";
div.append(p1,p2)
document.querySelector("#order_append").append(div)
});
let sum = 0
for(let i=0 ; i<arr.length ; i++){
sum = sum + arr[i].price
}
var total_div = document.getElementsByClassName("check_total");
for(let j = 0; j<total_div.length; j++){
total_div[j].innerHTML = sum;
}
var promo = document.getElementById("chk_btn");
promo.addEventListener("click", function() {
clicked();
})
function clicked(){
let val = document.querySelector(".check_coupon").value
if(val=="masaimasai"){
alert("Coupon Code Applied")
let res = sum*0.2
document.querySelector(".check_disc").textContent = res;
let total = sum - res ;
document.querySelector(".check_total").textContent=total;
}
else{
alert("Invalid code")
let res = 0
document.querySelector(".check_disc").textContent = 0;
}
}
</script>