Clearing the Cart After a Successful Order in Shopify Hydrogen

I’m facing an issue with my online store, which is built using Shopify’s headless solution with Hydrogen for the front-end and Shopify’s native checkout.

The problem I’m encountering is that after a user places an order and then returns to my store’s page, the shopping cart still contains the items from the previous order. Ideally, the cart should be cleared after an order is placed.

Hello @gabrielkarhub ,

Sounds like issue with cart session but without checking the code not possible to provide a solution.

btw try to contact the developer who make this setup for you or if you want you can drop an email to me.

Thanks

Hey @gabrielkarhub

Which version of Hydrogen are you using?

For the Storefront API in general, the cart will return null after a checkout is complete. If you’re fetching the cart on each page load (and not caching or storing), you should see null once the checkout completes.

1 Like

Hi @gabrielkarhub
I think you can check checkout graphQL mutation - https://shopify.dev/docs/api/storefront/2023-07/objects/Checkout If you’re using the same the you need to check in code if cart item are still present after checkout.

Let me know if you need help with code.
Thanks

1 Like

Could you explain to me where I got the checkout ID so I can make this query?

I found the problem.

I am using a third-party payment solution that is generating an error and this happens with cleaning