Show previous messages
Tips on building ecommerce with GatsbyJuly 30, 2018 at 5:33pm (Edited 4 years ago)
So I'm trying to figure out the best approach to building an ecommerce solution with Gatsby. What I'm thinking of doing is integrating Snipcart onto a Gatsby site and using Netlify's lambda functions to perform any backend actions.
What I'm struggling to get my head around is which parts should be generated as static pages, and which parts should be part of a "hybrid app".
I also should point out a couple of details:
- All the product data will be pulled in via an API call to an external service
- Each product "item" from the data set represents a single item. So my store will have no concept of a quantity of items in stock, only of an item is for sale or not.
Lets say the product listing & product detail pages are all generated during Gatsby's build step:
- The issue that I'm anticipating here is that there will be a gap when the site is rebuilding between when an item has been bought or source data has changed.
- In this window where the site is re-building customers browsing the site could potentially purchase an item that has just been purchased. (Though a check could possibly implemented here via SnipCart's webooks to prevent the item being purchased twice).
- I can see caching issues potentially cropping up here especially as site rebuilds would be automated.
The other solution I can see then is to have a "hybrid-app" which hits this API and renders the product data on the fly.
- So this would apply to the product listing & product detail pages, as it would ensure a user is seeing the current product data
- But this seems to defeat the point of using Gatsby as most of the site won't be statically generated.
If anyone has any experiences they could share or advice they could offer on this Ill be super thankful!
All the best,
May 18, 2019 at 5:23pm
Yes, it makes sense, but I will try to go another route (which will hopefully require less time). I will write a custom plugin to whitelist all metafields by creating a
MetafieldStorefrontVisibilityrecord using Admin API. After doing it I'm supposed to get read access to these fields from Storefront API.
The thing I'm not clear about if I will have to make any modifications to
gatsby-source-shopifyto be able to fetch newly available metafields?
May 20, 2019 at 8:41pm
November 22, 2019 at 1:23pm