diff --git a/src/app/checkout/client.tsx b/src/app/checkout/client.tsx index 22d3366..3199a2e 100644 --- a/src/app/checkout/client.tsx +++ b/src/app/checkout/client.tsx @@ -55,6 +55,9 @@ export default function CheckoutPageClient({ isLoggedIn, customer }: CheckoutPag setCheckingOut(true); setCheckoutError(null); try { + // Mark that we're checking out so LogoutOnUnload doesn't clear cart + sessionStorage.setItem('isCheckingOut', 'true'); + const res = await fetch('/api/checkout', { method: 'POST', headers: { 'Content-Type': 'application/json' }, @@ -70,6 +73,7 @@ export default function CheckoutPageClient({ isLoggedIn, customer }: CheckoutPag }); const data = await res.json(); if (!res.ok || !data.url) { + sessionStorage.removeItem('isCheckingOut'); throw new Error(data.error ?? 'Something went wrong starting checkout.'); } window.location.href = data.url;