-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckout.html
66 lines (62 loc) · 2.88 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>checkout</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<link rel="stylesheet" href="./CSS/signup.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/fontawesome.min.css">
<script src="https://kit.fontawesome.com/1bffa3735e.js" crossorigin="anonymous"></script>
</head>
<body>
<div class="login">
<div class="login_box">
<div class="left">
<div class="top"> <a href="./cart.html" style="color: #452A5A;"><i class="fa-solid fa-angle-left"></i> Return home</a> </div>
<div class="contact">
<form action="">
<h3 style="margin: 0; margin-bottom: 10px;">Enter Details</h3>
<input id="address" type="text" placeholder="ADDRESS" required>
<input id="phone" type="number" placeholder="PHONE NUMBER" required>
<input id="card-number" type="number" placeholder="CARD NUMBER" required>
<input id="date" type="date" placeholder="PHONE NUMBER" required>
<input id="code" type="password" placeholder="Security Code" required>
<p id="total"></p>
<button style="margin: 10px;" id="submit" type="submit">Place Order</button>
</form>
</div>
</div>
<div class="right">
<img src="./data/Lovepik_com-450091953-card with protection shield flat illustration of secure payment.png">
</div>
</div>
</div>
</body>
</html>
<script>
let value = document.querySelector('#total');
let cart = JSON.parse(localStorage.getItem('cart'));
value.innerText = "Total Price to Pay: " + JSON.parse(localStorage.getItem('total'));
let userdata = JSON.parse(localStorage.getItem('user'));
cart.push({'order' : JSON.parse(localStorage.getItem('total'))})
document.querySelector('#submit').addEventListener('click', (event) => {
event.preventDefault();
let address = document.querySelector('#address').value;
let phone = document.querySelector("#phone").value;
let card_number = +document.querySelector('#card-number').value;
let security_code = document.querySelector('#code').value;
if(+card_number == 16){
alert('Enter vaild Card Number');
return 0;
}
// userdata[0]['address'] = address;
// userdata[0]['phone'] = phone;
userdata[0]['orders'] = cart;
localStorage.setItem('user', JSON.stringify(userdata));
localStorage.removeItem('cart');
alert("Order Placed \nThank you for Trusting Us");
window.location = "./home.html";
})
</script>