-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpayment.js
77 lines (59 loc) · 2.35 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
localStorage.setItem("otp", 8840)
const place_order_redirect = () => {
let place_order_btn = document.getElementById("place_order_btn")
let first_name = document.getElementById("first_name")
let last_name = document.getElementById("last_name")
let address = document.getElementById("address")
let city = document.getElementById("city")
let state = document.getElementById("state")
let zipcode = document.getElementById("zipcode")
let credit_no = document.getElementById("credit_no")
place_order_btn.onclick = () => {
first_name.value = null
last_name.value = null
address.value = null
city.value = null
state.value = null
zipcode.value = null
credit_no.value = null
window.location.href = ""
}
}
place_order_redirect()
// localStorage.setItem("total_price", 2000)
const change_prices = () =>{
let item_subtotal_price = document.getElementById("item_subtotal_price")
let estimated_tax_price = document.getElementById("estimated_tax_price")
let subtotal_price = document.getElementById("subtotal_price")
let save_amount = document.getElementById("save_amount")
let total_price = JSON.parse(localStorage.getItem("total_price"))
let save_price = JSON.parse(localStorage.getItem('save_price'))
total_price = Number(total_price)
let tax = Math.floor(total_price/10)
item_subtotal_price.textContent = `$${total_price}`;
estimated_tax_price.textContent = `$${tax}`
subtotal_price.textContent = `$${total_price + tax}`;
save_amount.textContent = `$${save_price}`
}
change_prices()
place_order_click()
function place_order_click(){
let place_order_btn = document.getElementById('place_order_btn')
console.log(first_name, last_name)
place_order_btn.onclick = () => {
let name = getname()
let sign = prompt("PLease Enter your otp here");
if (sign == 8840) {
alert(`Your order is Successful Thank You so much ${name[0]} ${name[1]} for choosing us`)
window.location.href = "index.html"
localStorage.clear()
} else{
alert("Your otp is incorrect")
}
}
}
function getname(){
let first_name = document.getElementById('first_name').value;
let last_name = document.getElementById('last_name').value;
return [first_name, last_name]
}