-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkOutPage.js
95 lines (63 loc) · 2.05 KB
/
checkOutPage.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
var datas = JSON.parse(localStorage.getItem("productDetails"));
var checkOutCart = document.querySelector(".cartList");
var itemCountInCheckOutPage = document.getElementById("itemCount");
if (datas != null) {
itemCountInCheckOutPage.textContent = datas.length;
var priceArry = [];
var productNameArray = [];
for (let i = 0; i < datas.length; i++) {
checkOutCart.innerHTML += `
<div class="checkOutCard">
<div>
<img src=${datas[i].productImg} alt="">
</div>
<div>
<h4>${datas[i].productTitile}</h4>
<p> <small> x </small> 1</p>
<p> <span>Amount: Rs </span>
<span>${datas[i].productPrice}</span></p>
</div>
</div>
`;
productNameArray.push(datas[i].productTitile);
// total price counting
var productPrice = datas[i].productPrice;
productPrice = parseInt(productPrice);
priceArry.push(productPrice);
}
var count = 0;
for (let i = 0; i < priceArry.length; i++) {
count += priceArry[i];
}
// total price adedd in checkout page
var totalAmountDisplay = document.getElementById("totalAmountDisplay");
totalAmountDisplay.textContent = `${count}.00`;
}
// else{
// itemCountInCheckOutPage.textContent = 0;
// }
var cartCount = document.querySelector(".cart-acount");
if (datas != null) {
cartCount.textContent = datas.length;
}
// cart count adedd
var placeOrderBtn = document.getElementById("placeOrderBtn");
var cartCount = document.querySelector(".cart-acount");
if (datas != null) {
cartCount.textContent = datas.length;
// placeOrderBtn.addEventListener("click", orderConfirmMsg);
function orderConfirmMsg(){
location.href = "orderConform.html";
localStorage.clear()
}
}
else{
placeOrderBtn.addEventListener('click', ()=>{
var emptyMsg = document.querySelector(".cartEmptyMsg");
emptyMsg.classList.add('show')
})
}
// function orderConfirmMsg() {
// location.assign("http://127.0.0.1:5501/orderConform.html");
// localStorage.clear()
// }