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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 4.5
parent
24a20d0caa
commit
345e4b9656
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user