gatsbyjs / store.gatsbyjs.org

The Gatsby store for swag and other Gatsby goodies.
https://store.gatsbyjs.org
MIT License
615 stars 219 forks source link

Delete the cart if there’s an error loading it from Shopify #195

Closed jlengstorf closed 5 years ago

jlengstorf commented 5 years ago

If I add something to my cart, then leave the site, and that item sells out/gets removed before I come back, the cart comes back empty and the site completely fails to load. We need to add a check for a bad response when loading the saved cart and — if we can't load it — delete it entirely rather than borking the site.

isaac-martin commented 5 years ago

How is the cart data returned now? I did something similar on another website last week, although not using gatsby should be pretty similar process. Happy to have a look

jlengstorf commented 5 years ago

We create a Shopify checkout, then store its ID in localStorage. I think the fix here is to add a try/catch that just swallows a checkout error and creates a new checkout in this code: https://github.com/gatsbyjs/store.gatsbyjs.org/blob/625b0299f625303ad610d22611f9d878e8f50cfa/src/components/shared/Layout.js#L125-L133

Thanks, @isaac-martin!

b-barry commented 5 years ago

@jlengstorf and @isaac-martin I have just made the #202 to fix that :)

jlengstorf commented 5 years ago

Closed in #202