|
<!DOCTYPE html> |
|
<html lang="en"> |
|
<head> |
|
<meta charset="UTF-8"> |
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
<title>Cart</title> |
|
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"> |
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet"> |
|
<style> |
|
body { |
|
font-family: Arial, sans-serif; |
|
background-color: #fdf4e3; |
|
color: #333; |
|
} |
|
.top-bar { |
|
background-color: #FF6F3C; |
|
width: 100%; |
|
padding: 10px 15px; |
|
display: flex; |
|
align-items: center; |
|
} |
|
.back-link { |
|
display: flex; |
|
align-items: center; |
|
text-decoration: none; |
|
} |
|
.back-arrow { |
|
font-size: 1.8rem; |
|
color: #000; |
|
font-weight: bold; |
|
} |
|
.back-label { |
|
margin-left: 10px; |
|
color: white; |
|
font-weight: bold; |
|
font-size: 1rem; |
|
} |
|
.order-heading { |
|
color: #000; |
|
font-size: 2.5rem; |
|
font-weight: bold; |
|
text-align: center; |
|
margin-top: 30px; |
|
} |
|
.cart-container { |
|
max-width: 768px; |
|
margin: 20px auto; |
|
padding: 15px; |
|
background-color: #FFFFFF; |
|
border-radius: 10px; |
|
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); |
|
} |
|
.cart-item { |
|
display: flex; |
|
align-items: flex-start; |
|
justify-content: space-between; |
|
border: 1px solid #fdf4e3; |
|
padding: 15px; |
|
background-color: #fff; |
|
border-radius: 8px; |
|
margin-bottom: 10px; |
|
} |
|
.remove-btn { |
|
border: none; |
|
background-color: transparent; |
|
cursor: pointer; |
|
font-size: 1.2rem; |
|
color: red; |
|
} |
|
.image-wrapper { |
|
width: 80px; |
|
height: 80px; |
|
display: flex; |
|
align-items: center; |
|
justify-content: center; |
|
} |
|
.cart-item img { |
|
width: 70px; |
|
height: 70px; |
|
object-fit: cover; |
|
border-radius: 5px; |
|
border: 1px solid #ffcc80; |
|
} |
|
.cart-item img:hover { |
|
transform: scale(1.05); |
|
} |
|
.cart-item-details { |
|
flex: 1; |
|
margin-left: 15px; |
|
} |
|
.cart-item-title { |
|
font-size: 1.1rem; |
|
font-weight: bold; |
|
} |
|
.text-primary { |
|
color: #2e7d32; |
|
text-align: right; |
|
font-weight: bold; |
|
} |
|
.cart-item-quantity { |
|
display: flex; |
|
align-items: center; |
|
margin-top: 5px; |
|
} |
|
.cart-item-quantity button { |
|
width: 24px; |
|
height: 24px; |
|
border: none; |
|
background-color: #f0f0f0; |
|
font-size: 0.8rem; |
|
font-weight: bold; |
|
cursor: pointer; |
|
} |
|
.cart-item-quantity input { |
|
width: 40px; |
|
text-align: center; |
|
border: none; |
|
background-color: #f8f9fa; |
|
font-size: 1rem; |
|
margin: 0 5px; |
|
} |
|
.cart-summary { |
|
text-align: left; |
|
margin-top: 15px; |
|
padding: 20px; |
|
background-color: #fff; |
|
border-radius: 12px; |
|
border: 2px solid #fdf4e3; |
|
} |
|
.bill-details { |
|
display: grid; |
|
grid-template-columns: 1fr 1fr; |
|
grid-gap: 10px; |
|
margin-bottom: 10px; |
|
} |
|
.bill-details .label { |
|
font-weight: 600; |
|
font-size: 1rem; |
|
} |
|
.bill-details .amount { |
|
text-align: right; |
|
font-weight: 600; |
|
font-size: 1rem; |
|
} |
|
.dotted-line { |
|
border-bottom: 2px dotted #ccc; |
|
margin: 15px 0; |
|
} |
|
.total-bill { |
|
display: grid; |
|
grid-template-columns: 1fr 1fr; |
|
font-weight: 600; |
|
font-size: 1.2rem; |
|
} |
|
.total-bill .amount { |
|
text-align: right; |
|
color: #2e7d32; |
|
} |
|
.checkout-button { |
|
background-color: #A52A2A; |
|
color: #ffffff; |
|
padding: 12px; |
|
border-radius: 8px; |
|
border: none; |
|
width: 100%; |
|
font-size: 1rem; |
|
cursor: pointer; |
|
margin-top: 15px; |
|
} |
|
</style> |
|
</head> |
|
<body> |
|
<div class="top-bar"> |
|
<a href="/menu" class="back-link"> |
|
<span class="back-arrow">⟨</span> |
|
<span class="back-label">Back to Menu</span> |
|
</a> |
|
</div> |
|
|
|
<div class="order-heading">Your Cart</div> |
|
|
|
<div class="container"> |
|
<div class="cart-container"> |
|
{% for item in cart_items %} |
|
<div class="cart-item"> |
|
<div class="image-wrapper"> |
|
<img src="{{ item.Image1__c }}" alt="{{ item.Name }}" onerror="this.src='/static/placeholder.jpg';"> |
|
</div> |
|
<div class="cart-item-details"> |
|
<div class="cart-item-title">{{ item.Name }}</div> |
|
<div class="cart-item-addons"> |
|
<small class="text-muted">Add-ons: {{ item.Add_Ons__c }}</small> |
|
</div> |
|
<div class="cart-item-instructions"> |
|
<small class="text-muted">Instructions: {{ item.Instructions__c or "None" }}</small> |
|
</div> |
|
<div class="cart-item-quantity mt-2"> |
|
<button onclick="updateQuantity('decrease', '{{ item.Name }}', '{{ customer_email }}')">-</button> |
|
<input type="text" value="{{ item.Quantity__c|int }}" readonly data-item-name="{{ item.Name }}"> |
|
<button onclick="updateQuantity('increase', '{{ item.Name }}', '{{ customer_email }}')">+</button> |
|
</div> |
|
</div> |
|
<div class="cart-item-actions"> |
|
<button type="button" class="remove-btn" onclick="removeItemFromCart('{{ item.Name }}')"> |
|
<i class="bi bi-trash"></i> |
|
</button> |
|
<div class="text-primary">${{ item.Price__c }}</div> |
|
</div> |
|
</div> |
|
{% else %} |
|
<p>No items in your cart.</p> |
|
{% endfor %} |
|
|
|
<div class="cart-summary"> |
|
<div class="bill-details"> |
|
<div class="label">Subtotal</div> |
|
<div class="amount">${{ subtotal }}</div> |
|
</div> |
|
<div class="dotted-line"></div> |
|
<div class="total-bill"> |
|
<div class="label">Total</div> |
|
<div class="amount">${{ subtotal }}</div> |
|
</div> |
|
<button class="checkout-button" onclick="proceedToBill()">Generate Bill</button> |
|
</div> |
|
</div> |
|
</div> |
|
|
|
<script> |
|
function updateQuantity(action, itemName, customerEmail) { |
|
let quantityInput = document.querySelector(`input[data-item-name="${itemName}"]`); |
|
let quantity = parseInt(quantityInput.value); |
|
if (action === 'increase') { |
|
quantity++; |
|
} else if (action === 'decrease' && quantity > 1) { |
|
quantity--; |
|
} |
|
if (isNaN(quantity) || quantity < 1) { |
|
alert("Invalid quantity!"); |
|
return; |
|
} |
|
fetch('/cart/update_quantity', { |
|
method: 'POST', |
|
headers: { 'Content-Type': 'application/json' }, |
|
body: JSON.stringify({ email: customerEmail, item_name: itemName, quantity: quantity }) |
|
}) |
|
.then(response => response.json()) |
|
.then(data => { |
|
if (data.success) { |
|
quantityInput.value = quantity; |
|
location.reload(); |
|
} else { |
|
alert("Error updating quantity: " + data.error); |
|
} |
|
}) |
|
.catch(err => console.error("Error:", err)); |
|
} |
|
|
|
function removeItemFromCart(itemName) { |
|
fetch(`/cart/remove/${encodeURIComponent(itemName)}`, { |
|
method: 'POST', |
|
headers: { 'Content-Type': 'application/json' } |
|
}) |
|
.then(response => response.json()) |
|
.then(data => { |
|
if (data.success) { |
|
alert(data.message); |
|
location.reload(); |
|
} else { |
|
alert(data.message); |
|
} |
|
}) |
|
.catch(err => console.error('Error removing item:', err)); |
|
} |
|
|
|
function proceedToBill() { |
|
window.location.href = '/bill'; |
|
} |
|
</script> |
|
</body> |
|
</html> |