Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

How to clear localstorage/cookies (cart/checkout) on custom front-end? #237

Open
ollebergkvist opened this issue Nov 22, 2022 · 0 comments

Comments

@ollebergkvist
Copy link

ollebergkvist commented Nov 22, 2022

I just finished creating a Next.js app using the Storefront API.

However I can't see that there's a way to query the API to see if a checkout was completed, which
could be used to unset localStorage/cookie used to store a user's cart items...

As the checkout flow lives on another domain this is a bit tricky, my "work-around" fix was to create an API route to unset the cookie that contains the cart info server-side, and add a redirection to the home route.

So once the user ends up on the order confirmation page, a script runs to redirect them to the defined API route on the custom frontend...

It's a bit hacky and it's not the best UX.... also there's a risk that a user will close the window before the timeout...

Did I miss something crucial in the docs? Or was this scenario simply not considered?

Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant