forked from PrathyushNair/ToyMarche_clone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
piggy bank.js
69 lines (67 loc) · 1.98 KB
/
piggy bank.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
function buy(){
window.location.href="Buyback&sell.html"
}
function gotohome(){
window.location.href="home.html"
}
function gotoshop(){
window.location.href="shop.html"
}
function gotodonate(){
window.location.href="donate.html"
}
function gotorecycle(){
window.location.href="donate.html"
}
function gotopiggy(){
console.log("hello")
window.location.href="piggy bank.html"
}
function gotocontact(){
console.log("yo")
window.location.href="contactus.html"
}
function gotoshopping(){
window.location.href="shoppingguide.html"
}
function gotoaboutus(){
window.location.href=""
}
function gotoshop(){
window.location.href="shop.html"
}
var cartData = JSON.parse(localStorage.getItem("cart"))||[];
console.log(cartData);
// wish
var NewArriv = JSON.parse(localStorage.getItem("wish")) || []; //wish
console.log(NewArriv) ;
// Calculation---------------------------------------------------------------------------------->
var total = cartData.reduce(function (sum, elem, index, arr) {
return sum + Number(elem.price2);
}, 0);
var length = cartData.length;
console.log(length);
var length2 =NewArriv.length
console.log(total);
// Display Calculation---------------------------------------------------------------------------------->
var cartcoutup= document.querySelector(".cartcoutup").innerText = ` ${length}`
var cartcoutup= document.querySelector(".wishcoup").innerText = ` ${length2}`
function gotoshop2(){
select=document.querySelector("select").value
if(select=="Shop"){
window.location.href="shop.html"
}
else if(select=="Sell"){
window.location.href="sell.html"
}
}
username=document.querySelector("#username")
userarr=JSON.parse(localStorage.getItem("user"))
username.innerText="Hi!"+" "+userarr[0].name
function wishpage(){
window.location.href="wish.html"
}
function cartpage(){
console.log("in cart")
window.location.href="cart.html"
}