-
Notifications
You must be signed in to change notification settings - Fork 3
/
thanks.html
81 lines (64 loc) · 2.35 KB
/
thanks.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
<!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>Order Successful</title>
<link rel="icon" href="https://www.thebowlcompany.in/wp-content/uploads/2021/12/cropped-favicon1-01-1-192x192.png" sizes="192x192">
<link rel="stylesheet" href="./styles/thanks.css"/>
</head>
<body>
<div id="thanks_div">
<img src="https://www.knowband.com/blog/wp-content/uploads/2020/03/THANKYOU-PAGE-2.png" id ="thanks"/>
<div id="thanksbtn"><a href="index.html">Go to our website</a></div>
</div>
<!-- <img src="https://www.knowband.com/blog/wp-content/uploads/2020/03/THANKYOU-PAGE-2.png" id ="thanks"/> -->
</body>
</html>
<script>
let userCart=JSON.parse(localStorage.getItem("cartItem"));
let prodBag=JSON.parse(localStorage.getItem("DotAndKeyProducts"));
console.log(userCart)
let tab=document.querySelector("table");
let total=0;
userCart.map((item, index) => {
//console.log(item)
// filtering for same product id as original one
let prod = prodBag.filter((el) => {
if (item.id === el.id) {
return true;
}
});
let tr=document.createElement("tr");
let sr=document.createElement("td")
sr.textContent=index+1;
let title=document.createElement("td");
title.textContent=prod[0].title;
let quantity=document.createElement("td")
if(item.quantity){
quantity.textContent=item.quantity;
}else{
quantity.textContent=1;
}
let size=document.createElement("td")
if(item.size){
if(item.size=="Default"){
console.log(prod[0].size)
size.textContent=prod[0].size[0]
}else{
console.log(item.size)
size.textContent=item.size;
}
}
let price=document.createElement("td");
price.textContent=prod[0].price;
total+=+prod[0].price;
tr.prepend(sr,title,size,quantity,price);
tab.append(tr)
})
document.getElementById("total").textContent=`Subtotal Rs.${total.toFixed(2)}`
document.getElementById("orderid").textContent=`Order Id. D&k${Math.floor(Math.random()*10000)}`
let arr=[];
localStorage.setItem("cartItem",JSON.stringify(arr));
</script>