Skip to content

Commit 332dd00

Browse files
authored
Merge pull request #309 from layer0-docs/jeff/bigcommerce
BigCommerce guide write-up
2 parents 9c9e355 + fd6c7e6 commit 332dd00

16 files changed

+608
-236
lines changed

components/icons/Icon.js

+17-15
Original file line numberDiff line numberDiff line change
@@ -46,57 +46,59 @@ import SolidJS from './solid.svg'
4646
import UmiJS from './umijs.svg'
4747
import clsx from 'clsx'
4848
import RedwoodJSIcon from './redwood.svg'
49+
import BigCommerce from './bigcommerce.svg'
4950

5051
export const icons = {
5152
'next-commerce': NextCommerceIcon,
5253
'react-storefront': ReactStorefrontIcon,
5354
angular: AngularIcon,
5455
astro: AstroIcon,
56+
bigcommerce: BigCommerce,
57+
brunch: Brunch,
5558
docusaurus: Docusaurus,
59+
dojo: Dojo,
60+
eleventy: Eleventy,
5661
ember: Ember,
62+
express: ExpressIcon,
5763
fastboot: Fastboot,
5864
frontity: FrontityIcon,
5965
gatsby: GatsbyIcon,
66+
gridsome: Gridsome,
6067
hexo: Hexo,
61-
hugo: Hugo,
6268
html: HTMLIcon,
69+
hugo: Hugo,
70+
ionic_react: IonicReact,
71+
ionic_vue: IonicReact,
6372
jekyll: JekyllIcon,
6473
layer0: Layer0Icon,
6574
mkdocs: MkDocsIcon,
75+
mkdocs: MkDocsIcon,
6676
next: ChevronRight,
6777
nextjs: NextIcon,
6878
nuxt: NuxtIcon,
6979
nx: NXIcon,
80+
preact: Preact,
7081
prev: ChevronLeft,
7182
razzle: Razzle,
7283
razzleP: RazzlePng,
84+
react_static: ReactStatic,
7385
react: ReactIcon,
7486
redwood: RedwoodJSIcon,
7587
remix: Remix,
88+
saber: Saber,
7689
sapper: SapperIcon,
77-
stencil: Stencil,
7890
serverless_functions: ServerlessIcon,
7991
shopify_hydrogen: ShopifyHydrogen,
92+
solid: SolidJS,
8093
spartacus: SpartacusIcon,
94+
stencil: Stencil,
8195
svelte: SvelteIcon,
8296
swell: SwellIcon,
83-
mkdocs: MkDocsIcon,
84-
express: ExpressIcon,
97+
umijs: UmiJS,
8598
vsf: VSFIcon,
8699
vue: VueIcon,
87100
vuepress: VueIcon,
88-
react_static: ReactStatic,
89-
ionic_react: IonicReact,
90-
ionic_vue: IonicReact,
91-
gridsome: Gridsome,
92-
saber: Saber,
93-
preact: Preact,
94-
eleventy: Eleventy,
95-
brunch: Brunch,
96101
zola: Zola,
97-
dojo: Dojo,
98-
solid: SolidJS,
99-
umijs: UmiJS,
100102
}
101103

102104
export const styles = theme => ({

components/icons/bigcommerce.svg

+1
Loading

guides/bigcommerce.md

+170
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# BigCommerce
2+
3+
This guide shows you how to deploy a [BigCommerce](https://www.bigcommerce.com/) backed application on {{ PRODUCT_NAME }}.
4+
5+
## What is BigCommerce?
6+
7+
BigCommerce is an API driven ecommerce platform. Used by some of the biggest brands on the planet, BigCommerce provides solutions for B2B, wholesale, omnichannel, offline to online, international and multi-storefront. They provide deep integrations to social media platforms and have a robust partner network of technology and integration partners.
8+
9+
## Example
10+
11+
This example is a Next.js app powered by a BigCommerce backend.
12+
13+
[Try the Example Site](https://layer0-docs-layer0-nextjs-commerce-default.layer0-limelight.link/?button)
14+
[View the Code](https://github.com/layer0-docs/layer0-nextjs-commerce-example/?button)
15+
[Deploy to Layer0](https://app.layer0.co/deploy?button&deploy&repo=https://github.com/layer0-docs/layer0-nextjs-example)
16+
17+
{{ SIGN_UP_LAYER0 }}
18+
19+
## Install the {{ PRODUCT_NAME }} CLI
20+
21+
If you have not already done so, install the [{{ PRODUCT_NAME }} CLI](cli)
22+
23+
```bash
24+
npm i -g {{ PACKAGE_NAME }}/cli # yarn global add {{ PACKAGE_NAME }}/cli
25+
```
26+
27+
{{ SYSTEM_REQUIREMENTS }}
28+
29+
## Setting up a BigCommerce Headless Example
30+
31+
We will go through how to set-up your BigCommerce Storefront and the configuration it requires. There are two paths we can take here to generate a project to start:
32+
33+
1. Use our existing example
34+
2. Generate a [Next.js Commerce](https://nextjs.org/commerce) project from scratch
35+
36+
If you go with option 1, continue to the Storefront setup section.
37+
38+
### Generate a Next.js Commerce Project
39+
40+
1. Clone the official Next.js Commerce [repository](https://github.com/vercel/commerce) and install the dependencies.
41+
42+
```bash
43+
git clone [email protected]:vercel/commerce.git
44+
cd commerce
45+
yarn
46+
cd site
47+
```
48+
49+
2. Run {{ PRODUCT_NAME }} `init` in the project directory:
50+
51+
```
52+
{{ CLI_NAME }} init
53+
```
54+
55+
### Update the Example or Generated Project for use with BigCommerce
56+
57+
Skip to the [Storefront Setup][#storefront_setup] section for a detailed explanation on how to setup a BigCommerce site. After that, return to this section to enter values as needed.
58+
59+
1. Duplicate `.env.template` and name it `.env.local` in the project directory. Add your BigCommerce API keys to it. See Storefront setup for how to set these items up.
60+
61+
```
62+
COMMERCE_PROVIDER=@vercel/commerce-bigcommerce
63+
BIGCOMMERCE_STOREFRONT_API_URL=https://store-${STORE_HASH}-${CHANNEL_ID}.mybigcommerce.com/graphql
64+
BIGCOMMERCE_STOREFRONT_API_TOKEN=${STOREFRONT_API_TOKEN}
65+
BIGCOMMERCE_STORE_API_URL=https://api.bigcommerce.com/stores/${STORE_HASH}
66+
BIGCOMMERCE_STORE_API_TOKEN=${STORE_TOKEN}
67+
BIGCOMMERCE_STORE_API_CLIENT_ID=${STORE_CLIENT}
68+
BIGCOMMERCE_CHANNEL_ID=${CHANNEL_ID}
69+
BIGCOMMERCE_STORE_URL=https://store-${STORE_HASH}.mybigcommerce.com
70+
BIGCOMMERCE_STORE_API_STORE_HASH=${STORE_HASH}
71+
BIGCOMMERCE_STORE_API_CLIENT_SECRET=${CLIENT_SECRET}
72+
```
73+
74+
- STORE_HASH - Available in the URL bar of your BigCommerce site.
75+
- CHANNEL_ID - Available in the `Channel Manager > Channel / Advanced Settings > Channel Details`
76+
- STOREFRONT_API_TOKEN - The token result from the API call to create a token. This should be a long token.
77+
- STORE_TOKEN - The API token generated via the BigCommerce API KEY UI. This should be a short token.
78+
- STORE_CLIENT - The Client ID generated via the BigCommerce API KEY UI.
79+
- STORE_SECRET - The Client Secret generated via the BigCommerce API KEY UI.
80+
81+
Note: The `BIGCOMMERCE_STORE_API_URL` should not have the version at the end. The API KEY UI will show it this way, but do not include it in your environment variable.
82+
83+
2. Run the project.
84+
85+
From root of the project
86+
87+
```
88+
npm run dev
89+
```
90+
91+
### Deploy the project
92+
93+
From within the `site` directory, run
94+
95+
```
96+
0 deploy
97+
```
98+
99+
## BigCommerce Storefront Setup
100+
101+
1. [Login](https://login.bigcommerce.com/login) or [Signup](https://www.bigcommerce.com/start-your-trial) for an account with BigCommerce.
102+
103+
**Login**
104+
![](/images/bigcommerce/login.png?width=300)
105+
106+
**Signup**
107+
![](/images/bigcommerce/sign-up.png?width=1000)
108+
109+
2. After you have logged in or signed up, we need to generate an API key in order to continue creating the necessary elements to work with BigCommerce.
110+
111+
1. Visit `Advanced Settings > API Accounts` and click "Create API Account > Create V2/V3 API Token".
112+
113+
![](/images/bigcommerce/create-api-menu.png?width=1000)
114+
115+
1. Give the token a name and enable all scopes for now.
116+
117+
![](/images/bigcommerce/create-api-key.png?width=400)
118+
119+
1. Make note of the "API path" and save this somewhere, as we will need this later. It has a pattern of `https://api.bigcommerce.com/stores/{STORE_HASH}/v3/`.
120+
1. Click "Save".
121+
1. A dialog will appear with the generated API keys. Copy each item for later use. The credentials also get downloaded as a text file.
122+
123+
![](/images/bigcommerce/api-creds.png?width=400)
124+
125+
3. Now that we have API credentials, we will be able to interact with the BigCommerce API in order to finish setting up necessary elements.
126+
127+
**NOTE** As of the time of writing this guide, they only support setup via API.
128+
129+
For this next step you will need the store hash (available in the URL bar) and the API token you just created.
130+
131+
1. To create a channel we need to issue a `curl` request to the BigCommerce API. Open the API [doc](https://developer.bigcommerce.com/api-reference/b3A6MzU5MDQ0NDc-create-a-channel) for additional information. Use the `curl` below, substituting values where needed.
132+
133+
```
134+
curl --request POST \
135+
--url https://api.bigcommerce.com/stores/{STORE_HASH}/v3/channels \
136+
--header 'Content-Type: application/json' \
137+
--header 'X-Auth-Token: {API_ACCESS_TOKEN}' \
138+
--data '{
139+
"name": "Layer0",
140+
"platform": "custom",
141+
"type": "storefront",
142+
"status": "connected",
143+
"config_meta": {}
144+
}'
145+
```
146+
147+
2. Visit the `Channel Manager` to view your newly created Channel. Click the triple dot menu and select "Advanced settings". Make note of the Channel ID for later use in generating a GraphQL API token.
148+
149+
![](/images/bigcommerce/advanced-settings-menu.png?width=1000)
150+
151+
3. Click "Create Route" and create routes to match the below routes.
152+
153+
![](/images/bigcommerce/routes.png?width=600)
154+
155+
4. With a channel and routes created, the last item to use the BigCommerce API for is generating an Auth token for use with the GraphQL API. You will have to revisit this once you have deployed your application for the first time to add the allowed domain. Open the API [doc](https://developer.bigcommerce.com/api-reference/b3A6MzU5MDUxNTI-create-a-token#requestrunner) for additional information.
156+
157+
```
158+
curl --request POST \
159+
--url https://api.bigcommerce.com/stores/{STORE_HASH}/v3/storefront/api-token \
160+
--header 'Content-Type: application/json' \
161+
--header 'X-Auth-Token: {API_ACCESS_TOKEN}' \
162+
--data '{
163+
"channel_id": {CHANNEL_ID},
164+
"expires_at": 1620766652, // change this to a time in the future. To generate in Javascript: new Date("2022-12-31").getTime()
165+
"allowed_cors_origins":
166+
["https://www.yourstorefront.com"]
167+
}'
168+
```
169+
170+
Save the token response for use in your environment variables.

guides/guides.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@
186186
"as": "/guides/brunch",
187187
"href": "/guides/[...guide]"
188188
},
189+
{
190+
"text": "BigCommerce",
191+
"icon": "bigcommerce",
192+
"as": "/guides/bigcommerce",
193+
"href": "/guides/[...guide]"
194+
},
189195
{
190196
"text": "Docusaurus",
191197
"icon": "docusaurus",
@@ -564,4 +570,4 @@
564570
}
565571
]
566572
}
567-
]
573+
]

0 commit comments

Comments
 (0)