gatsby-shopify-starter | A Gatsby Shopify Starter | Ecommerce library
kandi X-RAY | gatsby-shopify-starter Summary
kandi X-RAY | gatsby-shopify-starter Summary
This is a Gatsby Shopify Store starter, complete with cart and checkout functionality, and styled with Theme-UI. It is available for configuration and use with any Shopify store.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- get list items
- triggers on the store
- Handle click inside a cart element
gatsby-shopify-starter Key Features
gatsby-shopify-starter Examples and Code Snippets
Community Discussions
Trending Discussions on gatsby-shopify-starter
QUESTION
I read https://www.gatsbyjs.org/docs/path-prefix/ and I added the following to gatsby-configs.js.
...ANSWER
Answered 2020-Aug-06 at 18:18Gatsby's pathPrefix
only prepends a string to your projects routes (url). Your deployment script(s) should handle where the public folder ends up on your server. If you really want to publish your gatsby project to somewhere other than /public
(locally) You will propbably need to do something like use fs
and path
in onPostBuild
in gatsby-node.js to move everything over to another directory. At the time or writing this, Gatsby doesn't directly support alternative build directories so you are on your own when using gatsby develop or gatsby serve to view this locally.
Try something like this in gatsby-node.js but change the paths to serve your needs. This example will publish your project to /public/blog
rather than the default /public
and is just a proof of concept but I tested it and it works:
QUESTION
So, I'm struggling to understand how Gatsby works. I'm using the https://www.gatsbyjs.org/starters/AlexanderProd/gatsby-shopify-starter/ which uses a Gatsby plugin called gatsby-source-shopify
. The plugin takes two params: shopName
and accessToken
. It looks like this in gatsby-config.js
:
ANSWER
Answered 2020-Mar-28 at 17:37As the code shows, it uses process.env.SHOP_NAME
where SHOP_NAME
is the name of the environment variable. Those files are declared at the root of the project using some naming such as .env.domain1.com
. In this file, you can store any desired variable to use it in your Gatsby configurations. When dealing with delicate variables (API keys, tokens, passwords, etc) it's recommended to use that way and ignore all .env
files in your .gitignore
.
When you trigger a command in Gatsby, you can pass it some variables, for example:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install gatsby-shopify-starter
If you haven't already, create a new Shopify Account and store.
Personally, I recommend signing up for their partner program where you can experiment with multiple different Development Stores for experimentation and transfer ownership to store owners when you are ready.
Login to your account and create a new store
Your URL should read yourStoreName.myshopify.com/admin, and you should see something akin to the following:
In your Admin view, create a private app: navigate to your Apps click the ( undiscoverable ) Manage private apps link at the bottom of your Apps page. select create a new private app, and you should see the following: Provide a private app name, leave your Admin API credentials as Read Access Towards the bottom check "Allow this app to access your storefront data using the Storefront API." Check Read product tags and Read customer tags in addition to the default permissions. Click Save.
In your Products view, click add product. For the best experience, I recommend filling in data for the following: Title Description Media Pricing ( Price ) Inventory (Quantity, Track Quantity) Shipping (Weight, Country of origin) Variants (Optional, as this starter supports variants)
I would recommend adding at least 2 products, with perhaps some variants ( i.e. in mine, I added a soft cover and a hard cover, for "materials"), see image below:
Let's connect your Shopify store to your Gatsby App now. First clone this repo to your computer. Open this repo in your code editor Run yarn install to install all dependencies Run yarn develop, and you should now see the following: Now, to pull in your own products from Shopify, all you need to do is update the .env.development variables in this project. The .env file will look as follows: GATSBY_SHOP_NAME = jeremy-superhi-project1 GATSBY_SHOPIFY_ACCESS_TOKEN = a3155a160132b0ae0bf6bc40fa1c0dc0 Your GATSBY_SHOPIFY_ACCESS_TOKEN will be your Storefront access token from your Shopify App. To access this, in your Shopify Store, navigate to Apps > Private Apps > <YourPrivateApp> page. Scroll to the bottom and you'll see your Storefront access token. Copy this token, and setGATSBY_SHOPIFY_ACCESS_TOKEN equal to your Storefront access token. Now, let's update the GATSBY_SHOPIFY_ACCESS_TOKEN. You can find this by looking at your Shopify Shop URL: https://<yourShopName>.myshopify.com/admin copy the <yourShopName> portion from the URL, and set GATSBY_SHOP_NAME equal to it. Now, stop your server and run gatsby clean. This clears your cache so you don't run into any problems. Next, run yarn develop and you should see the store populated with your shop items.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page