34943-vm/cart.php
Flatlogic Bot 0fcbb065ea 0001
2025-10-14 03:03:16 +00:00

219 lines
6.8 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your Cart - MajuroEats</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/feather-icons/4.28.0/feather.min.css">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
<style>
body {
font-family: 'Poppins', sans-serif;
background-color: #F8F9FA;
color: #333;
}
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem 2rem;
background-color: #FFFFFF;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
position: sticky;
top: 0;
z-index: 1000;
}
.navbar-brand {
font-size: 1.5rem;
font-weight: 700;
color: #40E0D0;
text-decoration: none;
}
.nav-links {
display: flex;
align-items: center;
gap: 1.5rem;
}
.nav-links a {
text-decoration: none;
color: #2E8B57;
font-weight: 600;
}
.container {
padding: 4rem 2rem;
max-width: 900px;
margin: auto;
}
.cart-container h1 {
text-align: center;
font-size: 2.5rem;
font-weight: 700;
color: #2E8B57;
margin-bottom: 2rem;
}
.cart-items {
background-color: #fff;
border-radius: 0.5rem;
padding: 2rem;
box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}
.cart-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem 0;
border-bottom: 1px solid #eee;
}
.cart-item:last-child {
border-bottom: none;
}
.item-details {
flex-grow: 1;
}
.item-details h3 {
margin: 0;
font-size: 1.1rem;
font-weight: 600;
}
.item-quantity {
display: flex;
align-items: center;
gap: 0.5rem;
}
.item-quantity input {
width: 50px;
text-align: center;
border: 1px solid #ccc;
border-radius: 0.25rem;
padding: 0.25rem;
}
.item-price {
font-weight: 600;
min-width: 80px;
text-align: right;
}
.remove-item {
color: #E04050;
cursor: pointer;
margin-left: 1rem;
}
.cart-summary {
margin-top: 2rem;
text-align: right;
}
.total-price {
font-size: 1.5rem;
font-weight: 700;
color: #2E8B57;
}
.checkout-btn {
background-color: #40E0D0;
color: #fff;
border: none;
padding: 0.8rem 2rem;
border-radius: 0.5rem;
cursor: pointer;
font-weight: 600;
font-size: 1rem;
text-decoration: none;
display: inline-block;
margin-top: 1rem;
transition: background-color 0.3s ease;
}
.checkout-btn:hover {
background-color: #2E8B57;
}
.empty-cart {
text-align: center;
padding: 3rem;
}
</style>
</head>
<body>
<nav class="navbar">
<a href="index.php" class="navbar-brand">MajuroEats</a>
<div class="nav-links">
<a href="restaurants.php">All Restaurants</a>
</div>
</nav>
<div class="container cart-container">
<h1>Your Shopping Cart</h1>
<div id="cart-content">
<!-- Cart items will be rendered here by JavaScript -->
</div>
</div>
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
const cartContent = document.getElementById('cart-content');
function renderCart() {
const cart = shoppingCart.getCart();
if (!cart.items || cart.items.length === 0) {
cartContent.innerHTML = '<div class="empty-cart"><p>Your cart is empty.</p><a href="restaurants.php" class="checkout-btn">Browse Restaurants</a></div>';
return;
}
let total = 0;
const itemsHtml = cart.items.map(item => {
const itemTotal = item.price * item.quantity;
total += itemTotal;
return `
<div class="cart-item" data-id="${item.id}">
<div class="item-details">
<h3>${item.name}</h3>
</div>
<div class="item-quantity">
<input type="number" value="${item.quantity}" min="1" onchange="updateQuantity(${item.id}, this.value)">
</div>
<div class="item-price">$${itemTotal.toFixed(2)}</div>
<div class="remove-item" onclick="removeItem(${item.id})">&times;</div>
</div>
`;
}).join('');
cartContent.innerHTML = `
<div class="cart-items">
${itemsHtml}
</div>
<div class="cart-summary">
<div class="total-price">Total: $${total.toFixed(2)}</div>
<a href="checkout.php" class="checkout-btn">Proceed to Checkout</a>
</div>
`;
}
window.updateQuantity = (itemId, quantity) => {
const cart = shoppingCart.getCart();
const item = cart.items.find(i => i.id === itemId);
if (item) {
item.quantity = parseInt(quantity, 10);
if (item.quantity < 1) item.quantity = 1;
shoppingCart.saveCart(cart);
renderCart();
shoppingCart.updateCartCount();
}
};
window.removeItem = (itemId) => {
if (confirm('Are you sure you want to remove this item?')) {
let cart = shoppingCart.getCart();
cart.items = cart.items.filter(i => i.id !== itemId);
if(cart.items.length === 0) {
cart.restaurantId = null;
}
shoppingCart.saveCart(cart);
renderCart();
shoppingCart.updateCartCount();
}
};
renderCart();
});
</script>
</body>
</html>