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

163 lines
5.7 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<?php session_start(); ?>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Checkout - MajuroEats</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet">
<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);
}
.navbar-brand {
font-size: 1.5rem;
font-weight: 700;
color: #40E0D0;
text-decoration: none;
}
.container {
padding: 4rem 2rem;
max-width: 800px;
margin: auto;
}
.checkout-container h1 {
text-align: center;
font-size: 2.5rem;
font-weight: 700;
color: #2E8B57;
margin-bottom: 2rem;
}
.checkout-form {
background-color: #fff;
padding: 2rem;
border-radius: 0.5rem;
box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}
.form-group {
margin-bottom: 1.5rem;
}
.form-group label {
display: block;
margin-bottom: 0.5rem;
font-weight: 600;
}
.form-group input, .form-group textarea {
width: 100%;
padding: 0.75rem;
border: 1px solid #ccc;
border-radius: 0.25rem;
font-size: 1rem;
}
.order-summary {
margin-top: 2rem;
background-color: #fff;
padding: 2rem;
border-radius: 0.5rem;
}
.order-summary h2 {
font-size: 1.5rem;
color: #2E8B57;
margin-bottom: 1rem;
}
.place-order-btn {
background-color: #40E0D0;
color: #fff;
border: none;
padding: 0.8rem 2rem;
border-radius: 0.5rem;
cursor: pointer;
font-weight: 600;
font-size: 1.1rem;
width: 100%;
margin-top: 1rem;
transition: background-color 0.3s ease;
}
.place-order-btn:hover {
background-color: #2E8B57;
}
</style>
</head>
<body>
<nav class="navbar">
<a href="index.php" class="navbar-brand">MajuroEats</a>
</nav>
<div class="container checkout-container">
<h1>Checkout</h1>
<div class="checkout-grid">
<form id="checkout-form" class="checkout-form" action="place_order.php" method="POST">
<h2>Delivery Information</h2>
<div class="form-group">
<label for="customer_name">Full Name</label>
<input type="text" id="customer_name" name="customer_name" value="<?php echo isset($_SESSION['user_name']) ? htmlspecialchars($_SESSION['user_name']) : ''; ?>" required>
</div>
<div class="form-group">
<label for="customer_email">Email Address</label>
<input type="email" id="customer_email" name="customer_email" value="<?php echo isset($_SESSION['user_email']) ? htmlspecialchars($_SESSION['user_email']) : ''; ?>" required>
</div>
<div class="form-group">
<label for="customer_phone">Phone Number</label>
<input type="tel" id="customer_phone" name="customer_phone">
</div>
<div class="form-group">
<label for="delivery_address">Delivery Address</label>
<textarea id="delivery_address" name="delivery_address" rows="3" required></textarea>
</div>
<input type="hidden" name="cart_data" id="cart_data">
<button type="submit" class="place-order-btn">Place Order</button>
</form>
<div class="order-summary">
<h2>Your Order</h2>
<div id="summary-items">
<!-- Summary items will be rendered here -->
</div>
<h3 id="summary-total"></h3>
</div>
</div>
</div>
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
const summaryItems = document.getElementById('summary-items');
const summaryTotal = document.getElementById('summary-total');
const cartDataInput = document.getElementById('cart_data');
const checkoutForm = document.getElementById('checkout-form');
const cart = shoppingCart.getCart();
if (!cart.items || cart.items.length === 0) {
window.location.href = 'cart.php';
return;
}
let total = 0;
const itemsHtml = cart.items.map(item => {
const itemTotal = item.price * item.quantity;
total += itemTotal;
return `<p>${item.name} <span>(x${item.quantity})</span> - <strong>$${itemTotal.toFixed(2)}</strong></p>`;
}).join('');
summaryItems.innerHTML = itemsHtml;
summaryTotal.textContent = `Total: $${total.toFixed(2)}`;
checkoutForm.addEventListener('submit', () => {
cartDataInput.value = JSON.stringify(cart);
});
});
</script>
</body>
</html>