Add guest checkout and admin login link

- Add guest checkout flow: customers can now complete orders without creating an account
  - New /checkout page with login or guest options
  - Guest form collects: full name, email, phone, address
  - Orders track guest info via guestName and guestPhone fields
- Update cart message to reflect guest option
- Add "Admin login" link to customer login page for clear navigation
- Update checkout API to accept and store guest information

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
Andymick
2026-07-16 20:10:42 +01:00
co-authored by Claude Haiku 4.5
parent 39f54dedee
commit 8edb5e1f5b
5 changed files with 275 additions and 25 deletions
+11
View File
@@ -21,6 +21,13 @@ type CheckoutCartItem = {
placementPreviewUrlBack: string | null;
};
type GuestInfo = {
name: string;
email: string;
phone: string;
address: string;
};
export async function POST(req: Request) {
if (!process.env.STRIPE_SECRET_KEY) {
return NextResponse.json(
@@ -40,6 +47,7 @@ export async function POST(req: Request) {
const body = await req.json();
const items: CheckoutCartItem[] = body.items ?? [];
const guest: GuestInfo | undefined = body.guest;
if (items.length === 0) {
return NextResponse.json({ error: 'Your bag is empty.' }, { status: 400 });
@@ -79,6 +87,9 @@ export async function POST(req: Request) {
status: 'PENDING',
total,
customerId: customer?.id,
email: guest?.email ?? customer?.email,
guestName: guest?.name,
guestPhone: guest?.phone,
items: {
create: pricedItems.map((i) => ({
productId: i.productId,