Skip to content
This repository was 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

@ollebergkvist

Description

@ollebergkvist

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions