Added new commerce variable

This commit is contained in:
Luis Alvarez 2021-03-23 11:26:34 -06:00
parent bfae57653f
commit a7d368a1f5
3 changed files with 11 additions and 10 deletions

View File

@ -1,5 +1,5 @@
# Only include the environment variables for a single provider # Available providers: bigcommerce, shopify
# To test a different provider, comment or remove the variables of other providers first COMMERCE_PROVIDER=bigcommerce
BIGCOMMERCE_STOREFRONT_API_URL= BIGCOMMERCE_STOREFRONT_API_URL=
BIGCOMMERCE_STOREFRONT_API_TOKEN= BIGCOMMERCE_STOREFRONT_API_TOKEN=

View File

@ -71,9 +71,7 @@ Next.js Commerce provides a set of utilities and functions to create new provide
### How to change providers ### How to change providers
Open `.env.local` and set the environment variables for the provider you would like to use (use `.env.template` as the base). Open `.env.local` and change the value of `COMMERCE_PROVIDER` to the provider you would like to use, then set the environment variables for that provider (use `.env.template` as the base).
Comment or remove environment variables of other providers to avoid conflicts.
### Features ### Features

View File

@ -10,11 +10,14 @@ const prettier = require('prettier')
const PROVIDERS = ['bigcommerce', 'shopify'] const PROVIDERS = ['bigcommerce', 'shopify']
function getProviderName() { function getProviderName() {
return process.env.BIGCOMMERCE_STOREFRONT_API_URL return (
? 'bigcommerce' process.env.COMMERCE_PROVIDER ||
: process.env.NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN (process.env.BIGCOMMERCE_STOREFRONT_API_URL
? 'shopify' ? 'bigcommerce'
: null : process.env.NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN
? 'shopify'
: null)
)
} }
function withCommerceConfig(nextConfig = {}) { function withCommerceConfig(nextConfig = {}) {