bigcommerce / storefront-data-hooks

Hooks for React Storefront UI Components
MIT License
166 stars 36 forks source link

Cart not emptying on checkout completion #117

Open mattdjenkinson opened 2 years ago

mattdjenkinson commented 2 years ago

Hey, just wondering if anyone else has run into this issue I'm having or if anyone can help.

I'm using the embedded checkout and once a checkout is complete the cart doesn't empty unless you do a full page refresh.

I'm using the "useCart" hook to display cart info.

Thanks

mattdjenkinson commented 2 years ago

Update

I've used the "onComplete" option from the embedded checkout to revalidate the cart which is working. Is this how it's supposed to be used?

Thanks

jorgemasta commented 2 years ago

Hey @mattdjenkinson, where are you setting that onComplete option?

mattdjenkinson commented 2 years ago

Hey Joe,

I'm setting it when calling the embedded checkout.

` await module.embedCheckout({

          containerId: "checkout",

          url: embedded_checkout_url,

          styles: styles,

          onSignOut: () => logout(),

          onComplete: () => revalidate(),
        });`