File size: 3,754 Bytes
5e87bec
 
 
 
 
 
 
3876e34
 
5e87bec
 
 
 
3876e34
 
 
 
 
 
 
 
5e87bec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3876e34
 
 
 
 
 
5e87bec
 
3876e34
5e87bec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
let cart = [];

// Product data
const products = {
    'day-pass': {
        name: 'Day Pass',
        price: 5,
        duration: '24 hours',
        image: 'http://static.photos/red/200x200/1'
    },
    'week-pass': {
        name: 'Week Pass',
        price: 30,
        duration: '7 days',
        image: 'http://static.photos/red/200x200/2'
    },
    'month-pass': {
        name: 'Month Pass',
        price: 100,
        duration: '30 days',
        image: 'http://static.photos/red/200x200/3'
    }
};
// Add to cart function
function addToCart(productId) {
    cart.push(products[productId]);
    updateCart();
    openCart();
}

// Update cart display
function updateCart() {
    const cartItemsEl = document.getElementById('cartItems');
    const cartTotalEl = document.getElementById('cartTotal');
    const checkoutItemsEl = document.getElementById('checkoutItems');
    const checkoutTotalEl = document.getElementById('checkoutTotal');
    
    // Clear existing items
    cartItemsEl.innerHTML = '';
    
    // Add each item to cart display
    cart.forEach(item => {
        const itemEl = document.createElement('div');
        itemEl.className = 'flex justify-between py-2 border-b border-gray-700';
        itemEl.innerHTML = `
            <div class="flex items-center gap-4">
                <img src="${item.image}" alt="${item.name}" class="w-12 h-12 rounded-md object-cover">
                <div>
                    <h3 class="font-bold">${item.name}</h3>
                    <p class="text-sm text-gray-400">${item.duration}</p>
                </div>
            </div>
            <div class="font-bold">₱${item.price}</div>
`;
        cartItemsEl.appendChild(itemEl);
    });
    
    // Calculate total
    const total = cart.reduce((sum, item) => sum + item.price, 0);
    cartTotalEl.textContent = `₱${total}`;
    
    // Update checkout summary
    checkoutItemsEl.textContent = `${cart.length} item${cart.length !== 1 ? 's' : ''}`;
    checkoutTotalEl.textContent = `₱${total}`;
}

// Cart modal functions
function openCart() {
    document.getElementById('cartModal').classList.remove('hidden');
}

function closeCart() {
    document.getElementById('cartModal').classList.add('hidden');
}

// Checkout functions
function proceedToCheckout() {
    closeCart();
    document.getElementById('checkoutModal').classList.remove('hidden');
}

function closeCheckout() {
    document.getElementById('checkoutModal').classList.add('hidden');
}

// Payment functions
function proceedToPayment() {
    const email = document.getElementById('email').value;
    
    if (!email) {
        alert('Please enter your email address');
        return;
    }
    
    closeCheckout();
    
    // Set payment details
    const total = cart.reduce((sum, item) => sum + item.price, 0);
    document.getElementById('paymentAmount').textContent = `₱${total}`;
    document.getElementById('paymentEmail').textContent = email;
    
    document.getElementById('paymentModal').classList.remove('hidden');
}

function closePayment() {
    document.getElementById('paymentModal').classList.add('hidden');
}

function completePayment() {
    closePayment();
    document.getElementById('successModal').classList.remove('hidden');
    
    // In a real app, you would send the order to your backend here
    console.log('Order completed:', {
        email: document.getElementById('email').value,
        items: cart,
        total: cart.reduce((sum, item) => sum + item.price, 0)
    });
    
    // Reset cart
    cart = [];
    updateCart();
}

function closeSuccess() {
    document.getElementById('successModal').classList.add('hidden');
}

// Initialize
document.addEventListener('DOMContentLoaded', () => {
    updateCart();
});