From 345e4b965689e56a2106e4c594d9f92955198147 Mon Sep 17 00:00:00 2001 From: Andymick Date: Sat, 18 Jul 2026 07:10:17 +0100 Subject: [PATCH] Fix cart clearing on success page Use empty dependency array to ensure clear() runs once on mount. Add logging and also clear isCheckingOut flag. Co-Authored-By: Claude Haiku 4.5 --- src/components/ClearCartOnMount.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/ClearCartOnMount.tsx b/src/components/ClearCartOnMount.tsx index 72c76e7..6c9cd10 100644 --- a/src/components/ClearCartOnMount.tsx +++ b/src/components/ClearCartOnMount.tsx @@ -5,8 +5,15 @@ import { useCart } from '@/lib/cartStore'; export default function ClearCartOnMount() { const clear = useCart((s) => s.clear); + useEffect(() => { + console.log('🧹 ClearCartOnMount: Clearing cart on success page'); clear(); - }, [clear]); + // Also clear the isCheckingOut flag if it was set + if (typeof window !== 'undefined') { + sessionStorage.removeItem('isCheckingOut'); + } + }, []); // Empty dependency array - run once on mount + return null; }