diff --git a/.env.example b/.env.example index 9ff0463db9..9bbc8fbdb7 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,9 @@ COMPANY_NAME="Vercel Inc." -TWITTER_CREATOR="@vercel" -TWITTER_SITE="https://nextjs.org/commerce" -SITE_NAME="Next.js Commerce" -SHOPIFY_REVALIDATION_SECRET="" -SHOPIFY_STOREFRONT_ACCESS_TOKEN="" -SHOPIFY_STORE_DOMAIN="[your-shopify-store-subdomain].myshopify.com" +NEXT_PUBLIC_VERCEL_URL="http://localhost:3000" +SFCC_CLIENT_ID="" +SFCC_ORGANIZATIONID="f_ecom_0000_000" +SFCC_SECRET="" +SFCC_SHORTCODE="000123" +SFCC_SITEID="RefArch" +SITE_NAME="ACME Store" +SFCC_REVALIDATION_SECRET="" diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index b3e65ae8c4..0000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,23 +0,0 @@ -module.exports = { - extends: ['next', 'prettier'], - plugins: ['unicorn'], - rules: { - 'no-unused-vars': [ - 'error', - { - args: 'after-used', - caughtErrors: 'none', - ignoreRestSiblings: true, - vars: 'all' - } - ], - 'prefer-const': 'error', - 'react-hooks/exhaustive-deps': 'error', - 'unicorn/filename-case': [ - 'error', - { - case: 'kebabCase' - } - ] - } -}; diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index b18fd29357..0000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,6 +0,0 @@ -version: 2 -updates: - - package-ecosystem: 'github-actions' - directory: '/' - schedule: - interval: 'weekly' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index f2fee2f8d3..0000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: test -on: pull_request - -# Cancel in progress workflows on pull_requests. -# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Checkout repo - uses: actions/checkout@v4 - - name: Set node version - uses: actions/setup-node@v3 - with: - node-version-file: '.nvmrc' - - name: Set pnpm version - uses: pnpm/action-setup@v2 - with: - run_install: false - version: 7 - - name: Cache node_modules - id: node-modules-cache - uses: actions/cache@v3 - with: - path: '**/node_modules' - key: node-modules-cache-${{ hashFiles('**/pnpm-lock.yaml') }} - - name: Install dependencies - if: steps.node-modules-cache.outputs.cache-hit != 'true' - run: pnpm install --no-frozen-lockfile - - name: Run tests - run: pnpm test diff --git a/.gitignore b/.gitignore index 0298027e4f..02cb02a371 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,7 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts +.env*.local + +# editors +.cursor diff --git a/.nvmrc b/.nvmrc deleted file mode 100644 index 3c032078a4..0000000000 --- a/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -18 diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 71df57cbc4..0000000000 --- a/.prettierignore +++ /dev/null @@ -1,3 +0,0 @@ -.vercel -.next -pnpm-lock.yaml diff --git a/.vscode/settings.json b/.vscode/settings.json index 3fbb4ab257..8345c107c1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,8 +2,8 @@ "typescript.tsdk": "node_modules/typescript/lib", "typescript.enablePromptUseWorkspaceTsdk": true, "editor.codeActionsOnSave": { - "source.fixAll": true, - "source.organizeImports": true, - "source.sortMembers": true + "source.fixAll": "explicit", + "source.organizeImports": "explicit", + "source.sortMembers": "explicit" } } diff --git a/README.md b/README.md index 981685d2ba..c8aa019d35 100644 --- a/README.md +++ b/README.md @@ -1,58 +1,62 @@ -[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fcommerce&project-name=commerce&repo-name=commerce&demo-title=Next.js%20Commerce&demo-url=https%3A%2F%2Fdemo.vercel.store&demo-image=https%3A%2F%2Fbigcommerce-demo-asset-ksvtgfvnd.vercel.app%2Fbigcommerce.png&env=COMPANY_NAME,SHOPIFY_REVALIDATION_SECRET,SHOPIFY_STORE_DOMAIN,SHOPIFY_STOREFRONT_ACCESS_TOKEN,SITE_NAME,TWITTER_CREATOR,TWITTER_SITE) +[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fcommerce-sfcc&env=COMPANY_NAME,NEXT_PUBLIC_VERCEL_URL,SFCC_CLIENT_ID,SFCC_ORGANIZATIONID,SFCC_SECRET,SFCC_SHORTCODE,SFCC_SITEID,SITE_NAME,SFCC_REVALIDATION_SECRET&project-name=nextjs-commerce-sfcc&repository-name=nextjs-commerce-sfcc&demo-title=ACME%20Store&demo-description=A%20high-performance%20ecommerce%20store%20built%20with%20Next.js%2C%20Vercel%2C%20and%20Salesforce%20Commerce%20Cloud&demo-url=https%3A%2F%2Fnextjs-salesforce-commerce-cloud.vercel.app%2F) -# Next.js Commerce +# Next.js Commerce + Salesforce Commerce Cloud -A Next.js 14 and App Router-ready ecommerce template featuring: +A high-perfomance, server-rendered Next.js App Router ecommerce application. -- Next.js App Router -- Optimized for SEO using Next.js's Metadata -- React Server Components (RSCs) and Suspense -- Server Actions for mutations -- Edge Runtime -- New fetching and caching paradigms -- Dynamic OG images -- Styling with Tailwind CSS -- Checkout and payments with Shopify -- Automatic light/dark mode based on system settings +This template uses React Server Components, Server Actions, _Suspense_, _useOptimistic_, _use cache_ and more. -

+## Providers -> Note: Looking for Next.js Commerce v1? View the [code](https://github.com/vercel/commerce/tree/v1), [demo](https://commerce-v1.vercel.store), and [release notes](https://github.com/vercel/commerce/releases/tag/v1). +This version of Next.js Commerce is integrated with Salesforce Commerce Cloud. The integration code for Salesforce Commerce Cloud can be found in the _lib/sfcc_ directory. -## Providers +For information on other commerce providers, additional details, and the core Next.js Commerce template, please refer to the official [Next.js Commerce repository](https://github.com/vercel/commerce). + +## Enviroment variables -Vercel will only be actively maintaining a Shopify version [as outlined in our vision and strategy for Next.js Commerce](https://github.com/vercel/commerce/pull/966). +This project requires the following environment variables for connecting to Salesforce Commerce Cloud: + +``` +SFCC_ORGANIZATIONID="" +SFCC_SHORTCODE="" +SFCC_SITEID="RefArch" +SFCC_CLIENT_ID="" +SFCC_SECRET="" +SITE_NAME="ACME Store" +SFCC_REVALIDATION_SECRET="" +``` -Vercel is happy to partner and work with any commerce provider to help them get a similar template up and running and listed below. Alternative providers should be able to fork this repository and swap out the `lib/shopify` file with their own implementation while leaving the rest of the template mostly unchanged. +- _SFCC_ORGANIZATIONID_: Salesforce Commerce Cloud Organization ID +- _SFCC_SHORTCODE_: Salesforce Commerce Cloud instance short code +- _SFCC_SITEID_: ID of the target site +- _SFCC_CLIENT_ID_: SLAS API Client ID +- _SFCC_SECRET_: SLAS API Client Secret +- _SITE_NAME_: User-defined name for the site +- _SFCC_REVALIDATION_SECRET_: User-defined string for on-demand revalidation -- Shopify (this repository) -- [BigCommerce](https://github.com/bigcommerce/nextjs-commerce) ([Demo](https://next-commerce-v2.vercel.app/)) -- [Medusa](https://github.com/medusajs/vercel-commerce) ([Demo](https://medusa-nextjs-commerce.vercel.app/)) -- [Saleor](https://github.com/saleor/nextjs-commerce) ([Demo](https://saleor-commerce.vercel.app/)) -- [Shopware](https://github.com/shopwareLabs/vercel-commerce) ([Demo](https://shopware-vercel-commerce-react.vercel.app/)) -- [Swell](https://github.com/swellstores/verswell-commerce) ([Demo](https://verswell-commerce.vercel.app/)) -- [Umbraco](https://github.com/umbraco/Umbraco.VercelCommerce.Demo) ([Demo](https://vercel-commerce-demo.umbraco.com/)) -- [Wix](https://github.com/wix/nextjs-commerce) ([Demo](https://wix-nextjs-commerce.vercel.app/)) +Please refer to the official Salesforce Commerce API documentation for details on how to retrieve these values: -> Note: Providers, if you are looking to use similar products for your demo, you can [download these assets](https://drive.google.com/file/d/1q_bKerjrwZgHwCw0ovfUMW6He9VtepO_/view?usp=sharing). +- [Base URL Configuration](https://developer.salesforce.com/docs/commerce/commerce-api/guide/base-url.html) +- [SLAS Authorization](https://developer.salesforce.com/docs/commerce/commerce-api/guide/authorization-for-shopper-apis.html) -## Integrations +## Store configuration -Integrations enable upgraded or additional functionality for Next.js Commerce +This project works with a standard Salesforce Commerce Cloud _RefArch_ site with minimal modifications. However, for the homepage to display content correctly, two product categories must be created: -- [Orama](https://github.com/oramasearch/nextjs-commerce) ([Demo](https://vercel-commerce.oramasearch.com/)) - - Upgrades search to include typeahead with dynamic re-rendering, vector-based similarity search, and JS-based configuration. - - Search runs entirely in the browser for smaller catalogs or on a CDN for larger. +- _hidden-homepage-carousel_: This category populates the main carousel on the homepage +- _hidden-homepage-featured-items_: This category populates the featured products section on the homepage + +Create these two categories and assign products to them within Business Manager. ## Running locally -You will need to use the environment variables [defined in `.env.example`](.env.example) to run Next.js Commerce. It's recommended you use [Vercel Environment Variables](https://vercel.com/docs/concepts/projects/environment-variables) for this, but a `.env` file is all that is necessary. +You will need to use the environment variables defined in _.env.example_ to run Next.js Commerce. It's recommended you use [Vercel Environment Variables](https://vercel.com/docs/concepts/projects/environment-variables) for this, but a _.env_ file is all that is necessary. -> Note: You should not commit your `.env` file or it will expose secrets that will allow others to control your Shopify store. +> Note: You should not commit your _.env_ file or it will expose secrets that will allow others to control your Salesforce Commerce Cloud store. -1. Install Vercel CLI: `npm i -g vercel` -2. Link local instance with Vercel and GitHub accounts (creates `.vercel` directory): `vercel link` -3. Download your environment variables: `vercel env pull` +1. Install Vercel CLI: _npm i -g vercel_ +2. Link local instance with Vercel and GitHub accounts (creates _.vercel_ directory): _vercel link_ +3. Download your environment variables: _vercel env pull_ ```bash pnpm install @@ -60,17 +64,3 @@ pnpm dev ``` Your app should now be running on [localhost:3000](http://localhost:3000/). - -
- Expand if you work at Vercel and want to run locally and / or contribute - -1. Run `vc link`. -1. Select the `Vercel Solutions` scope. -1. Connect to the existing `commerce-shopify` project. -1. Run `vc env pull` to get environment variables. -1. Run `pnpm dev` to ensure everything is working correctly. -
- -## Vercel, Next.js Commerce, and Shopify Integration Guide - -You can use this comprehensive [integration guide](http://vercel.com/docs/integrations/shopify) with step-by-step instructions on how to configure Shopify as a headless CMS using Next.js Commerce as your headless Shopify storefront on Vercel. diff --git a/app/[page]/layout.tsx b/app/[page]/layout.tsx index 453253dca7..d76dedda11 100644 --- a/app/[page]/layout.tsx +++ b/app/[page]/layout.tsx @@ -1,15 +1,12 @@ -import Footer from 'components/layout/footer'; -import { Suspense } from 'react'; +import Footer from "components/layout/footer"; export default function Layout({ children }: { children: React.ReactNode }) { return ( - + <>
-
- {children} -
+
{children}