-
Notifications
You must be signed in to change notification settings - Fork 2
/
paymentPage.html
228 lines (191 loc) · 7.88 KB
/
paymentPage.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
217
218
219
220
221
222
223
224
225
226
227
228
<!DOCTYPE html>
<html lang="en">
<head>
<title>payment page</title>
<link rel="stylesheet" href="./paymentPage.css">
<link rel="icon" type="image/x-icon" href="favicon (2).png">
<link rel="stylesheet" href="./navbar/navbar.css">
<link rel="stylesheet" href="footer.css"/>
</head>
<body>
<div id="navi">
</div>
<div id="container">
<div id="CardDetails">
<div id="cardDetailsDiv">
<h1 id="paymentAmount"></h1>
<form action="" id="paymentPage">
<input type="number" placeholder="Enter Card Details" id="cardNumber">
<div id="cardMonthYear">
<select name="" id="cardMonth">
<option value="select">select</option>
<option value="01"> 01</option>
<option value="02"> 02</option>
<option value="03"> 03</option>
<option value="04"> 04</option>
<option value="05"> 05</option>
<option value="06"> 06</option>
<option value="07"> 07</option>
<option value="08"> 08</option>
<option value="09"> 09</option>
<option value="10"> 10</option>
<option value="11"> 11</option>
<option value="12"> 12</option>
</select>
<input type="number" placeholder="YYYY" id="cardYear">
<input type="number" placeholder="CVV" id="cardCvv">
</div>
<input type="text" placeholder="Enter card holder name" id="cardName">
<input type="submit" id="submitbutton">
</form>
</div>
</div>
<div id="cartDetails">
<div id="products">
</div>
<div id="promoCode">
<form action="" id="promoForm">
<input type="text" placeholder="Gift card or Dicount code"id="inputPromo" style="border-radius:2px; width: 300px;height: 40px;">
<input type="submit" value="Apply" id="applybutton" style="color:white;border-radius: 10px;background-color: rgb(237, 231, 231);width: 80px; height: 50px; font-size: large;">
</form>
</div>
<div id="amountDetails">
<div>
<p>Subtotal</p>
<p id="subTootalTag"></p>
</div>
<div>
<p>Shipping</p>
<p>Free</p>
</div>
</div>
<div id="totalDetails">
<p> Total</p>
<p id="totalTag"></p>
</div>
</div>
</div>
<div id="footer">
</div>
</body>
<script type="module">
import nav from "./navbar.js"
var navi=document.getElementById("navi")
navi.innerHTML=nav()
// import footer from "footer_cmpt.js"
// var footerr=document.getElementById("footer")
// footerr.innerHTML=footerr()
// console.log(navi.innerHTML)
let loc_data=localStorage.getItem("headPhoneuserData")
// console.log(loc_data)
if(loc_data.length!=0){
document.getElementById("login_acc").innerText="Account"
}
else{
document.getElementById("login_acc").innerText="Login"
}
let acc=document.getElementById("login_acc")
if(acc.innerText="Account"){
acc.href="aboutperosn.html"
}
if(localStorage.getItem("Additemtocart")!=null){
let lc_len=localStorage.getItem("counter")
var lc_len_int=parseInt(lc_len)
console.log(typeof(lc_len_int))
// if(lc_len)
if(lc_len_int>0){
document.getElementById("cart").innerText=lc_len_int
}
}
else{
document.getElementById("cart").innerText=0
lc_len_int=0
lc_len=JSON.stringify(lc_len_int)
localStorage.setItem("counter",lc_len)
}
</script>
<script type="module">
import footer from "./footer_cmpt.js"
var footerr=document.getElementById("footer")
// console.log(footer)
footerr.innerHTML=footer()
</script>
<script src="./navbar/nav_compt.js"></script>
<script>
window.addEventListener("load",checkOutPageCreator)
var cartArr=JSON.parse(localStorage.getItem("Additemtocart")) || [];
var total=localStorage.getItem("headphoneCheckOutTotal");
var productsDiv=document.querySelector("#products");
if(cartArr.length==1){
productsDiv.setAttribute("style","height:77px");
}else if(cartArr.length==2){
productsDiv.setAttribute("style","height:154px");
}else{
productsDiv.setAttribute("style","height:235px");
}
function checkOutPageCreator(){
subtotalTag();
totalTag();
productsWindow();
}
function subtotalTag(){
var subTag=document.querySelector("#subTootalTag");
subTag.innerText='₹'+total;
}
function totalTag(){
var totTag=document.querySelector("#totalTag");
totTag.innerText="₹"+total;
}
function productsWindow(){
cartArr.forEach(element => {
var product=document.createElement("div");
product.setAttribute("class","product");
var imageDiv=document.createElement("div");
imageDiv.setAttribute("class","imageDiv");
var imageUrllink=element.imge_url;
var imageElement=document.createElement("img");
imageElement.setAttribute("class","image");
imageElement.src=imageUrllink;
var qntElement=document.createElement("div");
qntElement.setAttribute("class","qntOnImage");
qntElement.innerText=element.quantity;
imageDiv.append(imageElement,qntElement);
var detailsDiv=document.createElement("div");
detailsDiv.setAttribute("class","detailsDiv");
var nameElement=document.createElement("h5");
nameElement.setAttribute("class","nameElement");
nameElement.innerText=element.name;
var colorElement=document.createElement("p");
detailsDiv.append(nameElement,colorElement);
var priceDiv=document.createElement("div");
priceDiv.setAttribute("class", "priceDiv");
var price=((parseInt(element.price1))*(parseInt(element.quantity)));
var priceElement=document.createElement("h5");
priceElement.setAttribute("class","priceElement");
priceElement.innerText="₹"+price+".00";
priceDiv.append(priceElement);
product.append(imageDiv,detailsDiv,priceDiv);
document.querySelector("#products").append(product);
});
}
document.querySelector("#paymentPage").addEventListener("submit",cardValidate);
var totalAmount=parseInt(localStorage.getItem("headphoneCheckOutTotal"));
var totalAmountTag=document.querySelector("#paymentAmount");
totalAmountTag.innerText="The amount to pay is "+"₹"+totalAmount;
function cardValidate(){
event.preventDefault();
var cardNumber=document.querySelector("#cardNumber").value;
var cardMonth=document.querySelector("#cardMonth").value;
var cardYear=document.querySelector("#cardYear").value;
var cardCvv=document.querySelector("#cardCvv").value;
var cardName=document.querySelector("#cardName").value;
if(cardNumber.length==16 && cardMonth!="select" && cardYear.length==4 && parseInt(cardYear)>=2022 && cardCvv.length==3 && cardName!==""){
alert("Your order is successfully placed continue to shop");
window.location.href="index.html";
}
else{
alert("Error");
}
}
</script>
</html>