-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckout.html
More file actions
204 lines (171 loc) · 9.21 KB
/
checkout.html
File metadata and controls
204 lines (171 loc) · 9.21 KB
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Checkout — Henry's Cafe</title>
<meta name="description" content="Review your order and place it via WhatsApp."/>
<script src="https://cdn.tailwindcss.com?plugins=forms"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap" rel="stylesheet"/>
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&display=swap" rel="stylesheet"/>
<style>
*{box-sizing:border-box;margin:0;padding:0;}
body{font-family:'Inter',sans-serif;background:#fafafa;color:#1c1917;}
.material-symbols-outlined{font-variation-settings:'FILL' 0,'wght' 300,'GRAD' 0,'opsz' 24;font-size:1.1rem;vertical-align:middle;}
input,textarea{font-family:'Inter',sans-serif;}
.qty-btn{width:32px;height:32px;border:1px solid #e7e5e4;background:#fff;cursor:pointer;font-size:1rem;display:flex;align-items:center;justify-content:center;color:#1c1917;transition:background 0.2s;}
.qty-btn:hover{background:#f5f5f4;}
.field{display:flex;flex-direction:column;gap:0.4rem;}
.field label{font-size:0.7rem;letter-spacing:0.15em;text-transform:uppercase;font-weight:500;color:#78716c;}
.field input,.field textarea{padding:0.85rem 1rem;border:1px solid #e7e5e4;background:#fff;font-size:0.9rem;color:#1c1917;outline:none;transition:border-color 0.2s;resize:none;}
.field input:focus,.field textarea:focus{border-color:#1c1917;}
#place-order-btn{width:100%;padding:1.1rem;background:#1c1917;color:#fff;border:none;cursor:pointer;font-size:0.75rem;letter-spacing:0.15em;text-transform:uppercase;font-weight:500;font-family:'Inter',sans-serif;transition:background 0.2s;display:flex;align-items:center;justify-content:center;gap:0.6rem;}
#place-order-btn:hover{background:#44403c;}
#place-order-btn:disabled{background:#a8a29e;cursor:not-allowed;}
.divider{height:1px;background:#f3f4f6;margin:1.5rem 0;}
</style>
</head>
<body>
<!-- Nav -->
<header style="position:sticky;top:0;z-index:50;background:rgba(255,255,255,0.85);backdrop-filter:blur(12px);border-bottom:1px solid #f3f4f6;">
<div style="max-width:1200px;margin:auto;padding:1.25rem 2rem;display:flex;align-items:center;justify-content:space-between;">
<a href="index.html" style="font-size:0.75rem;letter-spacing:0.15em;text-transform:uppercase;font-weight:600;color:#1c1917;text-decoration:none;display:flex;align-items:center;gap:0.5rem;">
<span class="material-symbols-outlined">arrow_back</span> Back to Menu
</a>
<span style="font-size:0.75rem;letter-spacing:0.25em;text-transform:uppercase;font-weight:600;color:#1c1917;">Henry's Cafe</span>
</div>
</header>
<main style="max-width:1000px;margin:auto;padding:4rem 2rem;">
<!-- Page title -->
<div style="margin-bottom:3rem;">
<p style="font-size:0.7rem;letter-spacing:0.2em;text-transform:uppercase;color:#78716c;margin-bottom:0.5rem;">Review & Confirm</p>
<h1 style="font-size:2.25rem;font-weight:300;letter-spacing:-0.02em;color:#1c1917;">Your Order</h1>
</div>
<!-- Empty cart guard -->
<div id="empty-state" style="display:none;text-align:center;padding:5rem 2rem;">
<span class="material-symbols-outlined" style="font-size:3rem;color:#d6d3d1;">shopping_bag</span>
<p style="margin-top:1rem;color:#78716c;font-size:0.9rem;">Your cart is empty.</p>
<a href="index.html#menu" style="display:inline-block;margin-top:1.5rem;padding:0.75rem 2rem;background:#1c1917;color:#fff;font-size:0.75rem;letter-spacing:0.12em;text-transform:uppercase;text-decoration:none;">Browse Menu</a>
</div>
<!-- Checkout layout -->
<div id="checkout-layout" style="display:grid;grid-template-columns:1fr 1fr;gap:4rem;align-items:start;">
<!-- LEFT: Order Summary -->
<div>
<p style="font-size:0.7rem;letter-spacing:0.2em;text-transform:uppercase;font-weight:500;color:#78716c;margin-bottom:1.5rem;">Order Summary</p>
<div id="order-lines"></div>
<div class="divider"></div>
<div style="display:flex;justify-content:space-between;align-items:baseline;">
<span style="font-size:0.7rem;letter-spacing:0.15em;text-transform:uppercase;color:#78716c;">Subtotal</span>
<span id="order-total" style="font-size:1.25rem;font-weight:500;color:#1c1917;">$0.00</span>
</div>
<p style="margin-top:1rem;font-size:0.78rem;color:#a8a29e;line-height:1.6;">
Payment is collected in-store. This order is sent to us via WhatsApp — we'll confirm shortly!
</p>
</div>
<!-- RIGHT: Customer Details -->
<div>
<p style="font-size:0.7rem;letter-spacing:0.2em;text-transform:uppercase;font-weight:500;color:#78716c;margin-bottom:1.5rem;">Your Details</p>
<form id="checkout-form" style="display:flex;flex-direction:column;gap:1.25rem;" onsubmit="placeOrder(event)">
<div class="field">
<label for="customer-name">Full Name *</label>
<input id="customer-name" type="text" placeholder="e.g. Henry Ho" required autocomplete="name"/>
</div>
<div class="field">
<label for="customer-phone">Phone Number *</label>
<input id="customer-phone" type="tel" placeholder="e.g. 012-3456789" required autocomplete="tel"/>
</div>
<div class="field">
<label for="customer-notes">Special Requests <span style="font-weight:300;text-transform:none;letter-spacing:0;">(optional)</span></label>
<textarea id="customer-notes" rows="3" placeholder="e.g. Extra ice, less sugar..."></textarea>
</div>
<div class="divider" style="margin:0.5rem 0;"></div>
<button type="submit" id="place-order-btn">
<span class="material-symbols-outlined" style="font-size:1rem;">chat</span>
Place Order via WhatsApp
</button>
<p style="font-size:0.72rem;color:#a8a29e;text-align:center;line-height:1.6;">
Tapping the button will open WhatsApp with your order pre-filled. Simply hit Send!
</p>
</form>
</div>
</div>
</main>
<script>
const PRICES = {
'Signature Espresso': 4.50,
'Oat Milk Latte': 5.75,
'Cold Brew': 5.00,
'Sourdough': 8.00,
'Almond Croissant': 6.50
};
const WA_NUMBER = '60123456789'; // dummy number
let cart = JSON.parse(localStorage.getItem('hc_cart') || '{}');
function saveCart() { localStorage.setItem('hc_cart', JSON.stringify(cart)); }
function updateQty(name, delta) {
cart[name] = (cart[name] || 0) + delta;
if (cart[name] <= 0) delete cart[name];
saveCart();
renderOrder();
}
function renderOrder() {
const keys = Object.keys(cart);
const layout = document.getElementById('checkout-layout');
const empty = document.getElementById('empty-state');
if (keys.length === 0) {
layout.style.display = 'none';
empty.style.display = 'block';
return;
}
layout.style.display = 'grid';
empty.style.display = 'none';
let total = 0;
let html = '';
keys.forEach(name => {
const qty = cart[name];
const price = PRICES[name] || 0;
total += qty * price;
html += `
<div style="display:flex;align-items:center;gap:1rem;padding:1rem 0;border-bottom:1px solid #f3f4f6;">
<div style="flex:1;">
<p style="font-size:0.9rem;font-weight:500;color:#1c1917;">${name}</p>
<p style="font-size:0.8rem;color:#78716c;margin-top:0.2rem;">$${price.toFixed(2)} each</p>
</div>
<div style="display:flex;align-items:center;gap:0.5rem;">
<button class="qty-btn" onclick="updateQty('${name}',-1)">−</button>
<span style="font-size:0.9rem;font-weight:500;min-width:24px;text-align:center;">${qty}</span>
<button class="qty-btn" onclick="updateQty('${name}',1)">+</button>
</div>
<span style="font-size:0.9rem;font-weight:500;min-width:52px;text-align:right;color:#1c1917;">$${(qty*price).toFixed(2)}</span>
</div>`;
});
document.getElementById('order-lines').innerHTML = html;
document.getElementById('order-total').textContent = '$' + total.toFixed(2);
}
function placeOrder(e) {
e.preventDefault();
const name = document.getElementById('customer-name').value.trim();
const phone = document.getElementById('customer-phone').value.trim();
const notes = document.getElementById('customer-notes').value.trim();
const keys = Object.keys(cart);
if (keys.length === 0) return;
let lines = '';
let total = 0;
keys.forEach(n => {
const qty = cart[n];
const p = PRICES[n] || 0;
total += qty * p;
lines += `• ${n} x${qty} — $${(qty*p).toFixed(2)}\n`;
});
let msg = `Hello Henry's Cafe! 👋 I'd like to place an order:\n\n${lines}\n*Total: $${total.toFixed(2)}*\n\nName: ${name}\nPhone: ${phone}`;
if (notes) msg += `\nNotes: ${notes}`;
const url = `https://wa.me/${WA_NUMBER}?text=${encodeURIComponent(msg)}`;
window.open(url, '_blank');
}
renderOrder();
// Responsive: stack on mobile
const style = document.createElement('style');
style.textContent = '@media(max-width:680px){#checkout-layout{grid-template-columns:1fr!important;gap:2rem!important;}}';
document.head.appendChild(style);
</script>
</body>
</html>