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:
co-authored by
Claude Haiku 4.5
parent
39f54dedee
commit
8edb5e1f5b
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user