-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpayment.js
138 lines (102 loc) · 4.07 KB
/
payment.js
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
import navbar from "./cmmponents/navbar.js"
let navbar_div = document.getElementById("navbar")
navbar_div.innerHTML = navbar()
import footer from "./cmmponents/footer.js"
let footer_div = document.getElementById("footer")
footer_div.innerHTML = footer()
let total_cart_amout = localStorage.getItem("cart_total")
let cash_total = document.getElementById("cash_total_amount")
cash_total.innerText = total_cart_amout;
let card_total = document.getElementById("total_amount")
card_total.innerText = total_cart_amout;
let select = document.getElementById("change")
select.onchange =()=>{
handlePayment()
}
function handlePayment(){
let selected = document.getElementById("change").value
let prepaid = document.getElementById("Prepaid")
let COD = document.getElementById("COD")
if(selected=="COD"){
COD.style.display="block"
prepaid.style.display="none"
}else if(selected=="Prepaid"){
prepaid.style.display="block"
COD.style.display="none"
}
}
// let Cbtn=document.getElementById("cbtn")
// Cbtn.onclick=()=>{
// orderPlace()
// }
// function orderPlace(){
// alert("Hurray! Your order has been placed")
// }
// let Pbtn=document.getElementById("Pbtn")
// Pbtn.onclick=()=>{
// orderPlaced()
// }
// function orderPlaced(){
// alert("Hurray! Your order has been placed")
// }
// complete sentence
let customer = JSON.parse(localStorage.getItem("billing_address"))
let cus_name = document.getElementById("cus_name")
cus_name.innerText = customer.name;
let cus_address = document.getElementById("cus_address")
cus_address.innerText = customer.address;
let cus_city = document.getElementById("cus_city")
cus_city.innerText = customer.city;
let cus_state = document.getElementById("cus_state")
cus_state.innerText = customer.state;
let cus_pin = document.getElementById("cus_pincode")
cus_pin.innerText = customer.pincode;
let addedItems=JSON.parse(localStorage.getItem("cartitems")) || [];
let total_cart_products = document.getElementById("cartitems")
total_cart_products.innerText = addedItems.length;
let cash_button = document.getElementById("cbtn")
cash_button.onclick = ()=>{
localStorage.removeItem("cartitems")
total_cart_products.innerText = 0;
alert("Hurray! Your order has been placed")
window.location.href = "./index.html"
}
let card_button = document.getElementById("Pbtn")
card_button.onclick = ()=>{
let card_number = document.getElementById("card_number").value
let card_name = document.getElementById("card_name").value
let card_month = document.getElementById("card_month").value
let card_year = document.getElementById("card_year").value
let card_cvv = document.getElementById("card_cvv").value
if(card_number==""||card_name==""||card_month==""||card_year==""||card_cvv==""){
alert("please fill all details")
}
else if(card_number.length<16){
alert("Please fill complete Card Number")
}
else if(card_cvv.length<3 || card_cvv.length>3){
alert("Please fill correct cvv")
}
else{
localStorage.removeItem("cartitems")
total_cart_products.innerText = 0;
alert("Hurray! Your order has been placed")
window.location.href = "./index.html"
}
}
// login logout status
let homePage_username_logout_div = document.getElementById("username_logout_homePage_div")
let Username_onHomePage = document.getElementById("Username_onHomePage")
let homePage_logout_btn = document.getElementById("homePage_logout_btn")
let signup_login_homePage_div = document.getElementById("signup_login_homePage_div")
let login_logout_status = JSON.parse(localStorage.getItem("login_logout_status"))
if(login_logout_status.login_status=="loggedin"){
signup_login_homePage_div.style.display = "none";
Username_onHomePage.innerText = login_logout_status.username;
homePage_username_logout_div.style.display = "flex";
}
homePage_logout_btn.onclick = ()=>{
localStorage.removeItem("login_logout_status")
signup_login_homePage_div.style.display = "block";
homePage_username_logout_div.style.display = "none";
}