Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0a4408695 | ||
|
|
550bb1828d | ||
|
|
c56dc9340f | ||
|
|
233708e402 |
155
assets/js/main.js
Normal file
155
assets/js/main.js
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
// 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(name, price, quantityId) {
|
||||||
|
const quantityInput = document.getElementById(quantityId);
|
||||||
|
const quantity = parseInt(quantityInput.value, 10);
|
||||||
|
|
||||||
|
if (quantity < 1) {
|
||||||
|
alert("Quantity must be at least 1.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let cart = JSON.parse(localStorage.getItem('cart')) || {};
|
||||||
|
if (cart[name]) {
|
||||||
|
cart[name].quantity += quantity;
|
||||||
|
} else {
|
||||||
|
cart[name] = {
|
||||||
|
price: price,
|
||||||
|
quantity: quantity
|
||||||
|
};
|
||||||
|
}
|
||||||
|
localStorage.setItem('cart', JSON.stringify(cart));
|
||||||
|
updateCartCount();
|
||||||
|
updateButtonStates();
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateCartCount() {
|
||||||
|
let cart = JSON.parse(localStorage.getItem('cart')) || {};
|
||||||
|
let count = Object.values(cart).reduce((sum, item) => sum + item.quantity, 0);
|
||||||
|
const cartCountElement = document.getElementById('cart-count');
|
||||||
|
if (cartCountElement) {
|
||||||
|
cartCountElement.innerText = count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateButtonStates() {
|
||||||
|
let cart = JSON.parse(localStorage.getItem('cart')) || {};
|
||||||
|
const buttons = document.querySelectorAll('.buy-button');
|
||||||
|
buttons.forEach(button => {
|
||||||
|
const productName = button.getAttribute('data-product-name');
|
||||||
|
if (cart[productName]) {
|
||||||
|
button.textContent = 'In the cart';
|
||||||
|
button.disabled = true;
|
||||||
|
} else {
|
||||||
|
button.textContent = 'Buy';
|
||||||
|
button.disabled = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderCart() {
|
||||||
|
const cartContainer = document.getElementById('cart-container');
|
||||||
|
if (!cartContainer) return;
|
||||||
|
|
||||||
|
let cart = JSON.parse(localStorage.getItem('cart')) || {};
|
||||||
|
|
||||||
|
if (Object.keys(cart).length === 0) {
|
||||||
|
cartContainer.innerHTML = `
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body text-center">
|
||||||
|
<p>Your cart is currently empty.</p>
|
||||||
|
<a href="index.php#menu" class="btn btn-primary">Continue Shopping</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let table = `
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Item</th>
|
||||||
|
<th>Price</th>
|
||||||
|
<th>Quantity</th>
|
||||||
|
<th>Total</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
`;
|
||||||
|
|
||||||
|
let grandTotal = 0;
|
||||||
|
for (const name in cart) {
|
||||||
|
const item = cart[name];
|
||||||
|
const total = item.price * item.quantity;
|
||||||
|
grandTotal += total;
|
||||||
|
table += `
|
||||||
|
<tr>
|
||||||
|
<td>${name}</td>
|
||||||
|
<td>${item.price.toFixed(2)}</td>
|
||||||
|
<td>
|
||||||
|
<input type="number" class="form-control" value="${item.quantity}" min="1" style="width: 70px;" onchange="updateQuantity('${name}', this.value)">
|
||||||
|
</td>
|
||||||
|
<td id="total-${name}">${total.toFixed(2)}</td>
|
||||||
|
<td><button class="btn btn-danger btn-sm" onclick="removeFromCart('${name}')">Remove</button></td>
|
||||||
|
</tr>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
table += `
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<hr>
|
||||||
|
<div class="text-end">
|
||||||
|
<h4 id="grand-total">Grand Total: ${grandTotal.toFixed(2)}</h4>
|
||||||
|
<a href="checkout.php" class="btn btn-primary">Proceed to Checkout</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
cartContainer.innerHTML = table;
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateQuantity(name, newQuantity) {
|
||||||
|
let cart = JSON.parse(localStorage.getItem('cart')) || {};
|
||||||
|
const quantity = parseInt(newQuantity, 10);
|
||||||
|
|
||||||
|
if (quantity > 0) {
|
||||||
|
cart[name].quantity = quantity;
|
||||||
|
} else {
|
||||||
|
delete cart[name];
|
||||||
|
}
|
||||||
|
localStorage.setItem('cart', JSON.stringify(cart));
|
||||||
|
renderCart();
|
||||||
|
updateCartCount();
|
||||||
|
updateButtonStates();
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeFromCart(name) {
|
||||||
|
let cart = JSON.parse(localStorage.getItem('cart')) || {};
|
||||||
|
if (cart[name]) {
|
||||||
|
delete cart[name];
|
||||||
|
}
|
||||||
|
localStorage.setItem('cart', JSON.stringify(cart));
|
||||||
|
renderCart();
|
||||||
|
updateCartCount();
|
||||||
|
updateButtonStates(); // This is the key change
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update cart count on page load
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
updateCartCount();
|
||||||
|
updateButtonStates();
|
||||||
|
renderCart(); // To render cart on cart page
|
||||||
|
});
|
||||||
104
cart.php
Normal file
104
cart.php
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Shopping Cart - The Cozy Corner Cafe</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
--primary-color: #6b7b62;
|
||||||
|
--secondary-color: #8e9b83;
|
||||||
|
--background-color: #8e9b83;
|
||||||
|
--surface-color: #a2b199;
|
||||||
|
--text-color: #424c3b;
|
||||||
|
--heading-font: 'Inter', sans-serif;
|
||||||
|
--body-font: 'Inter', sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: var(--body-font);
|
||||||
|
color: var(--text-color);
|
||||||
|
background-color: var(--background-color);
|
||||||
|
padding-top: 70px; /* For fixed navbar */
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
font-family: var(--heading-font);
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar {
|
||||||
|
background-color: var(--background-color);
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
#cart-container .card {
|
||||||
|
background-color: #d4d4ce;
|
||||||
|
}
|
||||||
|
#cart-container .table {
|
||||||
|
--bs-table-bg: #d4d4ce;
|
||||||
|
}
|
||||||
|
#cart-container .form-control {
|
||||||
|
background-color: #d4d4ce;
|
||||||
|
border-color: var(--primary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
background-color: var(--text-color);
|
||||||
|
color: var(--secondary-color);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<header>
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light fixed-top shadow-sm">
|
||||||
|
<div class="container">
|
||||||
|
<a class="navbar-brand" href="index.php">The Cozy Corner</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
<ul class="navbar-nav ms-auto">
|
||||||
|
<li class="nav-item"><a class="nav-link" href="index.php#home">Home</a></li>
|
||||||
|
<li class="nav-item"><a class="nav-link" href="index.php#menu">Menu</a></li>
|
||||||
|
<li class="nav-item"><a class="nav-link" href="index.php#about">About</a></li>
|
||||||
|
<li class="nav-item"><a class="nav-link" href="index.php#contact">Contact</a></li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="cart.php">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-cart" viewBox="0 0 16 16">
|
||||||
|
<path d="M0 1.5A.5.5 0 0 1 .5 1H2a.5.5 0 0 1 .485.379L2.89 3H14.5a.5.5 0 0 1 .491.592l-1.5 8A.5.5 0 0 1 13 12H4a.5.5 0 0 1-.491-.408L2.01 3.607 1.61 2H.5a.5.5 0 0 1-.5-.5zM3.102 4l1.313 7h8.17l1.313-7H3.102zM5 12a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm7 0a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm-7 1a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm7 0a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
|
||||||
|
</svg>
|
||||||
|
<span class="badge bg-primary rounded-pill" id="cart-count">0</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main class="py-5">
|
||||||
|
<div class="container">
|
||||||
|
<h1 class="text-center mb-5">Shopping Cart</h1>
|
||||||
|
<div id="cart-container"></div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="py-4 text-center mt-auto">
|
||||||
|
<div class="container">
|
||||||
|
<p>© 2025 The Cozy Corner Cafe. All Rights Reserved.</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
193
checkout.php
Normal file
193
checkout.php
Normal file
@ -0,0 +1,193 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Checkout - The Cozy Corner Cafe</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
--primary-color: #6b7b62;
|
||||||
|
--secondary-color: #8e9b83;
|
||||||
|
--background-color: #8e9b83;
|
||||||
|
--surface-color: #a2b199;
|
||||||
|
--text-color: #424c3b;
|
||||||
|
--heading-font: 'Inter', sans-serif;
|
||||||
|
--body-font: 'Inter', sans-serif;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
font-family: var(--body-font);
|
||||||
|
color: var(--text-color);
|
||||||
|
background-color: var(--background-color);
|
||||||
|
padding-top: 70px; /* Adjusted for fixed navbar */
|
||||||
|
}
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
font-family: var(--heading-font);
|
||||||
|
}
|
||||||
|
.navbar {
|
||||||
|
background-color: var(--background-color);
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.form-control {
|
||||||
|
background-color: #d4d4ce;
|
||||||
|
border-color: var(--primary-color);
|
||||||
|
}
|
||||||
|
.btn-primary {
|
||||||
|
background-color: var(--primary-color);
|
||||||
|
border-color: var(--primary-color);
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
padding: 0.75rem 1.5rem;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.btn-primary:hover {
|
||||||
|
background-color: #5a6a54;
|
||||||
|
border-color: #5a6a54;
|
||||||
|
}
|
||||||
|
footer {
|
||||||
|
background-color: var(--text-color);
|
||||||
|
color: var(--secondary-color);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<header>
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light fixed-top shadow-sm">
|
||||||
|
<div class="container">
|
||||||
|
<a class="navbar-brand" href="index.php">The Cozy Corner</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
<ul class="navbar-nav ms-auto">
|
||||||
|
<li class="nav-item"><a class="nav-link" href="index.php#home">Home</a></li>
|
||||||
|
<li class="nav-item"><a class="nav-link" href="index.php#menu">Menu</a></li>
|
||||||
|
<li class="nav-item"><a class="nav-link" href="index.php#about">About</a></li>
|
||||||
|
<li class="nav-item"><a class="nav-link" href="index.php#contact">Contact</a></li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="cart.php">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-cart" viewBox="0 0 16 16">
|
||||||
|
<path d="M0 1.5A.5.5 0 0 1 .5 1H2a.5.5 0 0 1 .485.379L2.89 3H14.5a.5.5 0 0 1 .491.592l-1.5 8A.5.5 0 0 1 13 12H4a.5.5 0 0 1-.491-.408L2.01 3.607 1.61 2H.5a.5.5 0 0 1-.5-.5zM3.102 4l1.313 7h8.17l1.313-7H3.102zM5 12a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm7 0a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm-7 1a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm7 0a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
|
||||||
|
</svg>
|
||||||
|
<span class="badge bg-primary rounded-pill" id="cart-count">0</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main class="container py-5">
|
||||||
|
<h1 class="text-center mb-5">Checkout</h1>
|
||||||
|
<div class="row g-5">
|
||||||
|
<div class="col-md-7">
|
||||||
|
<div class="card" style="background-color: var(--surface-color);">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title mb-4">Payment Details</h5>
|
||||||
|
<form>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="cardName" class="form-label">Cardholder Name</label>
|
||||||
|
<input type="text" class="form-control" id="cardName" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="cardNumber" class="form-label">Card Number</label>
|
||||||
|
<input type="text" class="form-control" id="cardNumber" placeholder="•••• •••• •••• ••••" required>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="expiryDate" class="form-label">Expiry Date</label>
|
||||||
|
<input type="text" class="form-control" id="expiryDate" placeholder="MM / YY" required>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="cvc" class="form-label">CVC</label>
|
||||||
|
<input type="text" class="form-control" id="cvc" placeholder="•••" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary w-100">Pay Now</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-5">
|
||||||
|
<div class="card" style="background-color: var(--surface-color);">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title mb-4">Order Summary</h5>
|
||||||
|
<ul class="list-group list-group-flush" id="order-summary-list">
|
||||||
|
<!-- Cart items will be injected here by JS -->
|
||||||
|
</ul>
|
||||||
|
<div class="d-flex justify-content-between align-items-center mt-3">
|
||||||
|
<h5 class="mb-0">Total:</h5>
|
||||||
|
<h5 class="mb-0" id="grand-total"></h5>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="py-4 text-center mt-5">
|
||||||
|
<div class="container">
|
||||||
|
<p>© 2025 The Cozy Corner Cafe. All Rights Reserved.</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script>
|
||||||
|
function updateCartCount() {
|
||||||
|
let cart = JSON.parse(localStorage.getItem('cart')) || {};
|
||||||
|
let count = Object.values(cart).reduce((sum, item) => sum + item.quantity, 0);
|
||||||
|
document.getElementById('cart-count').innerText = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderOrderSummary() {
|
||||||
|
const summaryList = document.getElementById('order-summary-list');
|
||||||
|
const grandTotalEl = document.getElementById('grand-total');
|
||||||
|
let cart = JSON.parse(localStorage.getItem('cart')) || {};
|
||||||
|
let grandTotal = 0;
|
||||||
|
|
||||||
|
summaryList.innerHTML = ''; // Clear existing items
|
||||||
|
|
||||||
|
if (Object.keys(cart).length === 0) {
|
||||||
|
summaryList.innerHTML = '<li class="list-group-item" style="background-color: transparent;">Your cart is empty.</li>';
|
||||||
|
grandTotalEl.innerText = '$0.00';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const name in cart) {
|
||||||
|
const item = cart[name];
|
||||||
|
const total = item.price * item.quantity;
|
||||||
|
grandTotal += total;
|
||||||
|
const listItem = document.createElement('li');
|
||||||
|
listItem.className = 'list-group-item d-flex justify-content-between align-items-center';
|
||||||
|
listItem.style.backgroundColor = 'transparent';
|
||||||
|
listItem.innerHTML = `
|
||||||
|
<span>${item.quantity} x ${name}</span>
|
||||||
|
<span>${total.toFixed(2)}</span>
|
||||||
|
`;
|
||||||
|
summaryList.appendChild(listItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
grandTotalEl.innerText = `${grandTotal.toFixed(2)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
updateCartCount();
|
||||||
|
renderOrderSummary();
|
||||||
|
});
|
||||||
|
|
||||||
|
document.querySelector('form').addEventListener('submit', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
const cart = localStorage.getItem('cart');
|
||||||
|
if (cart) {
|
||||||
|
sessionStorage.setItem('order', cart);
|
||||||
|
}
|
||||||
|
window.location.href = 'order_confirmation.php';
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
40
contact_handler.php
Normal file
40
contact_handler.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
require_once __DIR__ . '/mail/MailService.php';
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
$name = filter_var(trim($_POST["name"]), FILTER_SANITIZE_STRING);
|
||||||
|
$email = filter_var(trim($_POST["email"]), FILTER_SANITIZE_EMAIL);
|
||||||
|
$message = filter_var(trim($_POST["message"]), FILTER_SANITIZE_STRING);
|
||||||
|
|
||||||
|
if (empty($name) || empty($email) || empty($message) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||||
|
$_SESSION['status'] = 'error';
|
||||||
|
$_SESSION['message'] = 'Please fill out all fields correctly.';
|
||||||
|
header("Location: index.php#contact");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The recipient email address.
|
||||||
|
// IMPORTANT: Replace this with your real email address.
|
||||||
|
$to = getenv('MAIL_TO') ?: 'your-email@example.com';
|
||||||
|
|
||||||
|
$res = MailService::sendContactMessage($name, $email, $message, $to, 'Contact Form Submission');
|
||||||
|
|
||||||
|
if (!empty($res['success'])) {
|
||||||
|
$_SESSION['status'] = 'success';
|
||||||
|
$_SESSION['message'] = 'Thank you for your message! We will get back to you shortly.';
|
||||||
|
} else {
|
||||||
|
$_SESSION['status'] = 'error';
|
||||||
|
$_SESSION['message'] = 'Sorry, there was an error sending your message. Please try again later.';
|
||||||
|
// It's a good practice to log the actual error for debugging
|
||||||
|
// error_log("MailService Error: " . $res['error']);
|
||||||
|
}
|
||||||
|
|
||||||
|
header("Location: index.php#contact");
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
// Not a POST request, redirect to the form
|
||||||
|
header("Location: index.php#contact");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
375
index.php
375
index.php
@ -1,150 +1,237 @@
|
|||||||
<?php
|
<?php session_start(); ?><!DOCTYPE html>
|
||||||
declare(strict_types=1);
|
|
||||||
@ini_set('display_errors', '1');
|
|
||||||
@error_reporting(E_ALL);
|
|
||||||
@date_default_timezone_set('UTC');
|
|
||||||
|
|
||||||
$phpVersion = PHP_VERSION;
|
|
||||||
$now = date('Y-m-d H:i:s');
|
|
||||||
?>
|
|
||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>New Style</title>
|
<title>The Cozy Corner Cafe</title>
|
||||||
<?php
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
// Read project preview data from environment
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
||||||
?>
|
<style>
|
||||||
<?php if ($projectDescription): ?>
|
:root {
|
||||||
<!-- Meta description -->
|
--primary-color: #6b7b62;
|
||||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
--secondary-color: #8e9b83;
|
||||||
<!-- Open Graph meta tags -->
|
--background-color: #8e9b83;
|
||||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
--surface-color: #a2b199;
|
||||||
<!-- Twitter meta tags -->
|
--text-color: #424c3b;
|
||||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
--heading-font: 'Inter', sans-serif;
|
||||||
<?php endif; ?>
|
--body-font: 'Inter', sans-serif;
|
||||||
<?php if ($projectImageUrl): ?>
|
}
|
||||||
<!-- Open Graph image -->
|
|
||||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
body {
|
||||||
<!-- Twitter image -->
|
font-family: var(--body-font);
|
||||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
color: var(--text-color);
|
||||||
<?php endif; ?>
|
background-color: var(--background-color);
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
}
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
h1, h2, h3, h4, h5, h6 {
|
||||||
<style>
|
font-family: var(--heading-font);
|
||||||
:root {
|
}
|
||||||
--bg-color-start: #6a11cb;
|
|
||||||
--bg-color-end: #2575fc;
|
.navbar {
|
||||||
--text-color: #ffffff;
|
background-color: var(--background-color);
|
||||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
font-weight: bold;
|
||||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
}
|
||||||
}
|
|
||||||
body {
|
.hero {
|
||||||
margin: 0;
|
background: url('https://m.media-amazon.com/images/I/41LmVVgTulL.jpg') no-repeat center center;
|
||||||
font-family: 'Inter', sans-serif;
|
background-size: cover;
|
||||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
padding: 6rem 0;
|
||||||
color: var(--text-color);
|
color: #f2eae2;
|
||||||
display: flex;
|
}
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
.hero .hero-text-container {
|
||||||
min-height: 100vh;
|
background-color: rgba(66, 76, 59, 0.7);
|
||||||
text-align: center;
|
display: inline-block;
|
||||||
overflow: hidden;
|
padding: 2rem;
|
||||||
position: relative;
|
border-radius: 0.5rem;
|
||||||
}
|
}
|
||||||
body::before {
|
|
||||||
content: '';
|
.hero h1, .hero .lead {
|
||||||
position: absolute;
|
text-shadow: 1px 1px 3px rgba(0,0,0,0.6);
|
||||||
top: 0;
|
}
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
.btn-primary {
|
||||||
height: 100%;
|
background-color: var(--primary-color);
|
||||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
|
border-color: var(--primary-color);
|
||||||
animation: bg-pan 20s linear infinite;
|
border-radius: 0.5rem;
|
||||||
z-index: -1;
|
padding: 0.75rem 1.5rem;
|
||||||
}
|
font-weight: bold;
|
||||||
@keyframes bg-pan {
|
}
|
||||||
0% { background-position: 0% 0%; }
|
|
||||||
100% { background-position: 100% 100%; }
|
.btn-primary:hover {
|
||||||
}
|
background-color: #5a6a54;
|
||||||
main {
|
border-color: #5a6a54;
|
||||||
padding: 2rem;
|
}
|
||||||
}
|
|
||||||
.card {
|
#menu .card {
|
||||||
background: var(--card-bg-color);
|
border: none;
|
||||||
border: 1px solid var(--card-border-color);
|
border-radius: 0.5rem;
|
||||||
border-radius: 16px;
|
background-color: var(--surface-color);
|
||||||
padding: 2rem;
|
}
|
||||||
backdrop-filter: blur(20px);
|
|
||||||
-webkit-backdrop-filter: blur(20px);
|
#menu .card .card-img-top {
|
||||||
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
height: 250px;
|
||||||
}
|
object-fit: cover;
|
||||||
.loader {
|
}
|
||||||
margin: 1.25rem auto 1.25rem;
|
|
||||||
width: 48px;
|
.form-control, .quantity-input {
|
||||||
height: 48px;
|
background-color: #d4d4ce;
|
||||||
border: 3px solid rgba(255, 255, 255, 0.25);
|
border-color: var(--primary-color);
|
||||||
border-top-color: #fff;
|
}
|
||||||
border-radius: 50%;
|
|
||||||
animation: spin 1s linear infinite;
|
#contact input.form-control, #contact textarea.form-control {
|
||||||
}
|
background-color: #d4d4ce;
|
||||||
@keyframes spin {
|
border-color: var(--primary-color);
|
||||||
from { transform: rotate(0deg); }
|
}
|
||||||
to { transform: rotate(360deg); }
|
|
||||||
}
|
footer {
|
||||||
.hint {
|
background-color: var(--text-color);
|
||||||
opacity: 0.9;
|
color: var(--secondary-color);
|
||||||
}
|
}
|
||||||
.sr-only {
|
</style>
|
||||||
position: absolute;
|
|
||||||
width: 1px; height: 1px;
|
|
||||||
padding: 0; margin: -1px;
|
|
||||||
overflow: hidden;
|
|
||||||
clip: rect(0, 0, 0, 0);
|
|
||||||
white-space: nowrap; border: 0;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 3rem;
|
|
||||||
font-weight: 700;
|
|
||||||
margin: 0 0 1rem;
|
|
||||||
letter-spacing: -1px;
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 0.5rem 0;
|
|
||||||
font-size: 1.1rem;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
background: rgba(0,0,0,0.2);
|
|
||||||
padding: 2px 6px;
|
|
||||||
border-radius: 4px;
|
|
||||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
||||||
}
|
|
||||||
footer {
|
|
||||||
position: absolute;
|
|
||||||
bottom: 1rem;
|
|
||||||
font-size: 0.8rem;
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main>
|
|
||||||
<div class="card">
|
<header>
|
||||||
<h1>Analyzing your requirements and generating your website…</h1>
|
<nav class="navbar navbar-expand-lg navbar-light fixed-top shadow-sm">
|
||||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
<div class="container">
|
||||||
<span class="sr-only">Loading…</span>
|
<a class="navbar-brand" href="#">The Cozy Corner</a>
|
||||||
</div>
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
||||||
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
<span class="navbar-toggler-icon"></span>
|
||||||
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
</button>
|
||||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
</div>
|
<ul class="navbar-nav ms-auto">
|
||||||
</main>
|
<li class="nav-item"><a class="nav-link" href="#home">Home</a></li>
|
||||||
<footer>
|
<li class="nav-item"><a class="nav-link" href="#menu">Menu</a></li>
|
||||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
<li class="nav-item"><a class="nav-link" href="#about">About</a></li>
|
||||||
</footer>
|
<li class="nav-item"><a class="nav-link" href="#contact">Contact</a></li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="cart.php">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-cart" viewBox="0 0 16 16">
|
||||||
|
<path d="M0 1.5A.5.5 0 0 1 .5 1H2a.5.5 0 0 1 .485.379L2.89 3H14.5a.5.5 0 0 1 .491.592l-1.5 8A.5.5 0 0 1 13 12H4a.5.5 0 0 1-.491-.408L2.01 3.607 1.61 2H.5a.5.5 0 0 1-.5-.5zM3.102 4l1.313 7h8.17l1.313-7H3.102zM5 12a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm7 0a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm-7 1a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm7 0a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
|
||||||
|
</svg>
|
||||||
|
<span class="badge bg-primary rounded-pill" id="cart-count">0</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<section id="home" class="hero text-center">
|
||||||
|
<div class="container">
|
||||||
|
<div class="hero-text-container">
|
||||||
|
<h1 class="display-3">Welcome to The Cozy Corner Cafe</h1>
|
||||||
|
<p class="lead">Where every cup is a warm hug.</p>
|
||||||
|
</div>
|
||||||
|
<a href="#menu" class="btn btn-primary btn-lg">View Our Menu</a>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section id="menu" class="py-5">
|
||||||
|
<div class="container">
|
||||||
|
<h2 class="text-center mb-5">Our Menu</h2>
|
||||||
|
<div class="row">
|
||||||
|
<!-- Menu Item 1 -->
|
||||||
|
<div class="col-lg-4 col-md-6 mb-4">
|
||||||
|
<div class="card h-100">
|
||||||
|
<img src="https://www.beserk.com.au/cdn/shop/files/gothic-gifts-striped-bat-wing-teacup-5.jpg?v=1721173226&width=600" class="card-img-top" alt="Classic Espresso">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">Classic Espresso</h5>
|
||||||
|
<p class="card-text">A rich and aromatic shot of pure coffee bliss.</p>
|
||||||
|
<p class="card-text fw-bold">$3.00</p>
|
||||||
|
<div class="d-flex justify-content-between align-items-center">
|
||||||
|
<input type="number" class="form-control" value="1" min="1" style="width: 60px;" id="quantity-espresso">
|
||||||
|
<button class="btn btn-primary buy-button" data-product-name="Classic Espresso" onclick="addToCart('Classic Espresso', 3.00, 'quantity-espresso')">Buy</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Menu Item 2 -->
|
||||||
|
<div class="col-lg-4 col-md-6 mb-4">
|
||||||
|
<div class="card h-100">
|
||||||
|
<img src="https://www.loveramics.co.uk/cdn/shop/products/C088-22BBK_0d522fb4-f764-4804-aa03-289a2aa451e2_1200x800.jpg?v=1645085617" class="card-img-top" alt="Creamy Latte">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">Creamy Latte</h5>
|
||||||
|
<p class="card-text">Espresso with steamed milk, topped with a light layer of foam.</p>
|
||||||
|
<p class="card-text fw-bold">$4.50</p>
|
||||||
|
<div class="d-flex justify-content-between align-items-center">
|
||||||
|
<input type="number" class="form-control" value="1" min="1" style="width: 60px;" id="quantity-latte">
|
||||||
|
<button class="btn btn-primary buy-button" data-product-name="Creamy Latte" onclick="addToCart('Creamy Latte', 4.50, 'quantity-latte')">Buy</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Menu Item 3 -->
|
||||||
|
<div class="col-lg-4 col-md-6 mb-4">
|
||||||
|
<div class="card h-100">
|
||||||
|
<img src="https://i.ytimg.com/vi/Ldgm3YD-tMQ/maxresdefault.jpg" class="card-img-top" alt="Chocolate Croissant">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">Chocolate Croissant</h5>
|
||||||
|
<p class="card-text">Flaky, buttery pastry with a rich dark chocolate filling.</p>
|
||||||
|
<p class="card-text fw-bold">$3.50</p>
|
||||||
|
<div class="d-flex justify-content-between align-items-center">
|
||||||
|
<input type="number" class="form-control" value="1" min="1" style="width: 60px;" id="quantity-croissant">
|
||||||
|
<button class="btn btn-primary buy-button" data-product-name="Chocolate Croissant" onclick="addToCart('Chocolate Croissant', 3.50, 'quantity-croissant')">Buy</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section id="about" class="py-5" style="background-color: var(--surface-color);">
|
||||||
|
<div class="container">
|
||||||
|
<h2 class="text-center mb-4">About Us</h2>
|
||||||
|
<p class="lead text-center mx-auto" style="max-width: 800px;">Founded in 2023, The Cozy Corner Cafe is a place for friends to gather, for students to study, and for everyone to enjoy a moment of peace with a delicious cup of coffee. We believe in quality, community, and the simple joy of a great brew.</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section id="contact" class="py-5">
|
||||||
|
<div class="container">
|
||||||
|
<h2 class="text-center mb-4">Contact Us</h2>
|
||||||
|
<?php if (isset($_SESSION['message'])): ?>
|
||||||
|
<div class="alert alert-<?php echo $_SESSION['status'] == 'success' ? 'success' : 'danger'; ?> alert-dismissible fade show" role="alert">
|
||||||
|
<?php echo $_SESSION['message']; ?>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
unset($_SESSION['message']);
|
||||||
|
unset($_SESSION['status']);
|
||||||
|
?>
|
||||||
|
<?php endif; ?>
|
||||||
|
<form action="contact_handler.php" method="POST" class="mx-auto" style="max-width: 600px;">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="name" class="form-label">Name</label>
|
||||||
|
<input type="text" class="form-control" id="name" name="name" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="email" class="form-label">Email</label>
|
||||||
|
<input type="email" class="form-control" id="email" name="email" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="message" class="form-label">Message</label>
|
||||||
|
<textarea class="form-control" id="message" name="message" rows="4" required></textarea>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">Send Message</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="py-4 text-center">
|
||||||
|
<div class="container">
|
||||||
|
<p>© 2025 The Cozy Corner Cafe. All Rights Reserved.</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
168
order_confirmation.php
Normal file
168
order_confirmation.php
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Order Confirmation - The Cozy Corner Cafe</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
--primary-color: #6b7b62;
|
||||||
|
--secondary-color: #8e9b83;
|
||||||
|
--background-color: #8e9b83;
|
||||||
|
--surface-color: #a2b199;
|
||||||
|
--text-color: #424c3b;
|
||||||
|
--heading-font: 'Inter', sans-serif;
|
||||||
|
--body-font: 'Inter', sans-serif;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
font-family: var(--body-font);
|
||||||
|
color: var(--text-color);
|
||||||
|
background-color: var(--background-color);
|
||||||
|
padding-top: 70px; /* Adjusted for fixed navbar */
|
||||||
|
}
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
font-family: var(--heading-font);
|
||||||
|
}
|
||||||
|
.navbar {
|
||||||
|
background-color: var(--background-color);
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.btn-primary {
|
||||||
|
background-color: var(--primary-color);
|
||||||
|
border-color: var(--primary-color);
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
padding: 0.75rem 1.5rem;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.btn-primary:hover {
|
||||||
|
background-color: #5a6a54;
|
||||||
|
border-color: #5a6a54;
|
||||||
|
}
|
||||||
|
footer {
|
||||||
|
background-color: var(--text-color);
|
||||||
|
color: var(--secondary-color);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<header>
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light fixed-top shadow-sm">
|
||||||
|
<div class="container">
|
||||||
|
<a class="navbar-brand" href="index.php">The Cozy Corner</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
<ul class="navbar-nav ms-auto">
|
||||||
|
<li class="nav-item"><a class="nav-link" href="index.php#home">Home</a></li>
|
||||||
|
<li class="nav-item"><a class="nav-link" href="index.php#menu">Menu</a></li>
|
||||||
|
<li class="nav-item"><a class="nav-link" href="index.php#about">About</a></li>
|
||||||
|
<li class="nav-item"><a class="nav-link" href="index.php#contact">Contact</a></li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="cart.php">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-cart" viewBox="0 0 16 16">
|
||||||
|
<path d="M0 1.5A.5.5 0 0 1 .5 1H2a.5.5 0 0 1 .485.379L2.89 3H14.5a.5.5 0 0 1 .491.592l-1.5 8A.5.5 0 0 1 13 12H4a.5.5 0 0 1-.491-.408L2.01 3.607 1.61 2H.5a.5.5 0 0 1-.5-.5zM3.102 4l1.313 7h8.17l1.313-7H3.102zM5 12a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm7 0a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm-7 1a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm7 0a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
|
||||||
|
</svg>
|
||||||
|
<span class="badge bg-primary rounded-pill" id="cart-count">0</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main class="container py-5">
|
||||||
|
<div class="text-center">
|
||||||
|
<h1 class="display-4">Thank You!</h1>
|
||||||
|
<p class="lead">Your order has been placed successfully.</p>
|
||||||
|
<hr>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-8 mx-auto">
|
||||||
|
<h5 class="text-center mb-4">Your Order Summary</h5>
|
||||||
|
<div id="order-summary"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="text-center mt-4">
|
||||||
|
<p>You will receive an email confirmation shortly.</p>
|
||||||
|
<a href="index.php" class="btn btn-primary">Continue Shopping</a>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="py-4 text-center mt-5">
|
||||||
|
<div class="container">
|
||||||
|
<p>© 2025 The Cozy Corner Cafe. All Rights Reserved.</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
renderOrderSummary();
|
||||||
|
updateCartCount();
|
||||||
|
localStorage.removeItem('cart'); // Clear cart from localStorage
|
||||||
|
});
|
||||||
|
|
||||||
|
function renderOrderSummary() {
|
||||||
|
const orderSummaryContainer = document.getElementById('order-summary');
|
||||||
|
const orderData = sessionStorage.getItem('order');
|
||||||
|
|
||||||
|
if (!orderData) {
|
||||||
|
orderSummaryContainer.innerHTML = '<p>No order details found.</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const order = JSON.parse(orderData);
|
||||||
|
let table = `
|
||||||
|
<table class="table" style="background-color: #d4d4ce;">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Item</th>
|
||||||
|
<th>Price</th>
|
||||||
|
<th>Quantity</th>
|
||||||
|
<th>Total</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
`;
|
||||||
|
|
||||||
|
let grandTotal = 0;
|
||||||
|
for (const name in order) {
|
||||||
|
const item = order[name];
|
||||||
|
const total = item.price * item.quantity;
|
||||||
|
grandTotal += total;
|
||||||
|
table += `
|
||||||
|
<tr>
|
||||||
|
<td>${name}</td>
|
||||||
|
<td>${item.price.toFixed(2)}</td>
|
||||||
|
<td>${item.quantity}</td>
|
||||||
|
<td>${total.toFixed(2)}</td>
|
||||||
|
</tr>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
table += `
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<hr>
|
||||||
|
<div class="text-end">
|
||||||
|
<h4>Grand Total: ${grandTotal.toFixed(2)}</h4>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
orderSummaryContainer.innerHTML = table;
|
||||||
|
sessionStorage.removeItem('order'); // Clear order from sessionStorage
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateCartCount() {
|
||||||
|
document.getElementById('cart-count').innerText = '0';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
x
Reference in New Issue
Block a user