Fix wishlist items not saving: pass customerId into toggleWishlistItem

The create POST omitted the customer relationship field entirely, so
added items never matched getWishlist's customer-scoped query. Also
scope the toggle-off fallback lookup to the current customer.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Marco
2026-08-01 15:04:35 +00:00
parent d010a3aff1
commit 51632b1668
2 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ export async function POST(request: Request) {
return NextResponse.json({ ok: false, reason: "Ungültiges Produkt." }, { status: 400 });
}
const result = await toggleWishlistItem(session.token, productId, variant);
const result = await toggleWishlistItem(session.token, session.customer.id, productId, variant);
if (!result.ok) return NextResponse.json({ ok: false, reason: "Merkliste konnte nicht aktualisiert werden." }, { status: 500 });
return NextResponse.json({ ok: true, wishlisted: result.wishlisted });
}