Add debug logging for checkout and LogoutOnUnload
Add console logs to track: - When isCheckingOut flag is set in checkout button - When LogoutOnUnload handleUnload is called - Whether isCheckingOut flag is detected - When redirecting to Stripe URL This helps diagnose why cart is still being cleared during checkout. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 4.5
parent
4dfbffc9ce
commit
7434b68a79
@@ -16,11 +16,14 @@ export default function LogoutOnUnload() {
|
||||
// Don't logout if we're in the middle of checkout (navigating to Stripe)
|
||||
// The checkout component sets this flag before making the API call
|
||||
const isCheckingOut = typeof window !== 'undefined' && sessionStorage.getItem('isCheckingOut');
|
||||
console.log('LogoutOnUnload handleUnload called, isCheckingOut flag:', isCheckingOut);
|
||||
if (isCheckingOut) {
|
||||
console.log('Skipping logout because isCheckingOut is set');
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear cart on logout
|
||||
console.log('Clearing cart and logging out');
|
||||
clearCart();
|
||||
// Use sendBeacon to reliably send logout even when page is closing
|
||||
// This doesn't wait for a response, which is fine for logout
|
||||
|
||||
Reference in New Issue
Block a user