File size: 1,072 Bytes
884b0e4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// Initialize cart functionality
let cart = [];

document.addEventListener('DOMContentLoaded', () => {
    // Cart count update
    updateCartCount();
    
    // Smooth scrolling for anchor links
    document.querySelectorAll('a[href^="#"]').forEach(anchor => {
        anchor.addEventListener('click', function (e) {
            e.preventDefault();
            document.querySelector(this.getAttribute('href')).scrollIntoView({
                behavior: 'smooth'
            });
        });
    });
});

function addToCart(product) {
    cart.push(product);
    updateCartCount();
    // In a real app, you'd probably show a notification here
}

function updateCartCount() {
    const cartCountElements = document.querySelectorAll('.cart-count');
    cartCountElements.forEach(el => {
        el.textContent = cart.length > 0 ? cart.length : '';
    });
}

// Simple cart toggle (would be expanded in a real app)
function toggleCart() {
    console.log("Cart would open now with", cart.length, "items");
    // In reality, you'd show a modal or sidebar with cart items
}