-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
39 lines (31 loc) · 1.13 KB
/
script.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
function show1()
{
document.getElementById('biscuitID').style.display = "flex";
document.getElementById('biscuitID').style.justifyContent = "space-around";
document.getElementById('chocolateID').style.display="none";
}
function show2()
{
document.getElementById('biscuitID').style.display = "none";
}
function show3()
{
document.getElementById('chocolateID').style.display = "flex";
document.getElementById('chocolateID').style.justifyContent = "space-around";
document.getElementById('biscuitID').style.display = "none";
}
function show4()
{
document.getElementById('chocolateID').style.display = "none";
}
let cart = JSON.parse(localStorage.getItem('cart')) || [];
function addToCart(productName, price) {
const product = { name: productName, price: price };
cart.push(product);
localStorage.setItem('cart', JSON.stringify(cart)); // Save cart to localStorage
updateCartCount();
alert(`${productName} has been added to your cart.`);
}
function updateCartCount() {
document.getElementById('cart-count').textContent = `(${cart.length})`;
}