diff --git a/.env.template b/.env.template index 5139a1b26..9e42e2f31 100644 --- a/.env.template +++ b/.env.template @@ -1,5 +1,5 @@ -# Only include the environment variables for a single provider -# To test a different provider, comment or remove the variables of other providers first +# Available providers: bigcommerce, shopify +COMMERCE_PROVIDER=bigcommerce BIGCOMMERCE_STOREFRONT_API_URL= BIGCOMMERCE_STOREFRONT_API_TOKEN= diff --git a/README.md b/README.md index 079583b77..cd4351911 100644 --- a/README.md +++ b/README.md @@ -71,9 +71,7 @@ Next.js Commerce provides a set of utilities and functions to create new provide ### 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). - -Comment or remove environment variables of other providers to avoid conflicts. +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). ### Features diff --git a/framework/commerce/config.js b/framework/commerce/config.js index a337f26bb..c3406f760 100644 --- a/framework/commerce/config.js +++ b/framework/commerce/config.js @@ -10,11 +10,14 @@ const prettier = require('prettier') const PROVIDERS = ['bigcommerce', 'shopify'] function getProviderName() { - return process.env.BIGCOMMERCE_STOREFRONT_API_URL - ? 'bigcommerce' - : process.env.NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN - ? 'shopify' - : null + return ( + process.env.COMMERCE_PROVIDER || + (process.env.BIGCOMMERCE_STOREFRONT_API_URL + ? 'bigcommerce' + : process.env.NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN + ? 'shopify' + : null) + ) } function withCommerceConfig(nextConfig = {}) {