From 5c95ea4e7d6f0642e3cd6c957c04a2c1fffe8f87 Mon Sep 17 00:00:00 2001 From: chrisvdm Date: Tue, 16 Jul 2024 14:41:21 +0200 Subject: [PATCH] Add condition to effect --- web/src/pages/SuccessPage/SuccessPage.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/web/src/pages/SuccessPage/SuccessPage.js b/web/src/pages/SuccessPage/SuccessPage.js index 567351d1..be246be1 100644 --- a/web/src/pages/SuccessPage/SuccessPage.js +++ b/web/src/pages/SuccessPage/SuccessPage.js @@ -8,13 +8,15 @@ import { MetaTags } from '@redwoodjs/web' import CheckoutSuccessCell from 'src/components/CheckoutSuccessCell/CheckoutSuccessCell' const SuccessPage = () => { - const { clearCart } = useStripeCart() + const { clearCart, cart } = useStripeCart() const { sessionId } = useParams() // OnMount clear the cart contents useEffect(() => { - clearCart() - }) + if (cart.length > 0) { + clearCart() + } + }, [clearCart, cart]) return ( <>