mirror of
https://github.com/vercel/commerce.git
synced 2025-06-08 17:26:59 +00:00
Feat: Implement dummy data mode controlled by environment variable This commit introduces a dummy data mode for the storefront, controlled by the `NEXT_PUBLIC_USE_DUMMY_DATA` environment variable. When this variable is set to `true`, the application will use hardcoded dummy data instead of making live calls to the Shopify API. Key changes: - Added `NEXT_PUBLIC_USE_DUMMY_DATA=true` to `.env.example`. - Restored `lib/shopify/index.ts#shopifyFetch` to its original implementation that can make live API calls. - Modified all data fetching functions in `lib/shopify/index.ts` (e.g., `getMenu`, `getCart`, `getProduct`, `getProducts`, `getCollection`, `getCollectionProducts`, `getPage`, `getPages`) to check `process.env.NEXT_PUBLIC_USE_DUMMY_DATA`. If true, they now return appropriate hardcoded dummy data. Otherwise, they proceed with the original Shopify API call logic. - Modified all cart mutation functions in `lib/shopify/index.ts` (`createCart`, `addToCart`, `removeFromCart`, `updateCart`) to also respect this environment variable. In dummy mode, they log the action and return a dummy cart state, bypassing actual API calls and cookie manipulations. A shared dummy cart constant was introduced for consistency. This allows the application to be run and tested in a standalone configuration without requiring a live Shopify backend, resolving previous build errors related to API call failures in such environments.
7 lines
278 B
Plaintext
7 lines
278 B
Plaintext
COMPANY_NAME="Vercel Inc."
|
|
COMMERCE_PROVIDER=crystallize
|
|
NEXT_PUBLIC_COMMERCE_PROVIDER=crystallize
|
|
CRYSTALLIZE_API_URL=https://api.crystallize.com/6422a2c186ef95b31e1cd1e5/graphql
|
|
CRYSTALLIZE_ACCESS_TOKEN=c3ab0fef20aadcbeb9919e6701f015cfb4ddf1ff
|
|
NEXT_PUBLIC_USE_DUMMY_DATA=true
|