-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
72 lines (64 loc) · 2.39 KB
/
index.html
File metadata and controls
72 lines (64 loc) · 2.39 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chips Shop</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;700&family=Pacifico&display=swap" rel="stylesheet">
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>The Chips Shop</h1>
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="shop.html">Order Now</a></li>
<li><a href="about.html">About Us</a></li>
<li><a href="contact.html">Contact</a></li>
<li><a href="cart.html">Cart</a></li> <!-- Link to the cart page -->
</ul>
</nav>
</header>
<main>
<div class="banner-background"></div>
<section class="welcome-section">
<h2>Welcome to The Chips Shop</h2>
<p>Discover a variety of delicious chips and snacks crafted with love and passion. Explore our unique flavors and find your perfect snack.</p>
<a href="shop.html" class="discover-now-btn">Discover Now</a>
</section>
</main>
<footer>
<p1>© 2024 The Chips Shop. All rights reserved. <span> serikalidevelopmentsolutions@2024</span> </p1>
</footer>
<script>
document.addEventListener('DOMContentLoaded', () => {
let cart = JSON.parse(localStorage.getItem('cart')) || [];
const updateLocalStorage = () => {
localStorage.setItem('cart', JSON.stringify(cart));
};
const addToCart = (product) => {
const existingProduct = cart.find(item => item.name === product.name);
if (existingProduct) {
existingProduct.quantity += 1;
} else {
cart.push({ ...product, quantity: 1 });
}
updateLocalStorage();
alert(`${product.name} added to cart`);
};
const addToCartButtons = document.querySelectorAll('.add-to-cart');
addToCartButtons.forEach(button => {
button.addEventListener('click', (e) => {
e.preventDefault();
const productName = e.target.getAttribute('data-name');
const productPrice = e.target.getAttribute('data-price');
const product = { name: productName, price: productPrice };
addToCart(product);
});
});
});
</script>
</body>
</html>