Fix cart clearing when navigating to checkout

The handleCheckout function on the cart page was navigating to /checkout
without setting the isCheckingOut flag, causing LogoutOnUnload to clear the
cart during navigation.

Now sets the flag BEFORE navigating so LogoutOnUnload skips clearing the cart.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
Andymick
2026-07-18 07:05:07 +01:00
co-authored by Claude Haiku 4.5
parent eff9a72409
commit 6ca99fa118
+5
View File
@@ -17,6 +17,11 @@ export default function CartPage() {
useEffect(() => setMounted(true), []); useEffect(() => setMounted(true), []);
const handleCheckout = () => { const handleCheckout = () => {
// Set flag so LogoutOnUnload doesn't clear cart during navigation to checkout
if (typeof window !== 'undefined') {
sessionStorage.setItem('isCheckingOut', 'true');
console.log('💳 Cart checkout button clicked - set isCheckingOut flag');
}
window.location.href = '/checkout'; window.location.href = '/checkout';
}; };