🌟 Welcome to the Commerce on Lightning Web Components Starter Kit! 🛍️
We're excited to present you with an ongoing development journey that aims to provide comprehensive building blocks for every aspect of your commerce storefront. If you're a customer or partner looking to create a remarkable commerce storefront that dazzles your users, then you've come to the right place.
While the project is still in active development, we're committed to gradually releasing the essential components you need. Each release will bring you closer to achieving a seamless and efficient commerce experience. The goal is that with our meticulously crafted reference components at your disposal, you'll be able to effortlessly assemble dynamic product catalogs, seamless shopping carts, intuitive checkout processes, and so much more. You can focus on what truly matters – crafting a storefront that not only meets your customers' expectations but exceeds them.
Join us on this exciting adventure as we shape the future of commerce storefront development together. Happy coding and happy commerce building! ✨🚀
As you might expect, this project is organized as an SFDX (Salesforce DX) project. And because this is a project that consists almost exclusively of Lightning Web Components (LWC) intended for use in a B2B/B2C on LWR commerce storefront, everything essential is thus located in the force-app/main/default/lwc
directory.
Installing the components using a Scratch Org
-
Set up your environment. Follow the steps in the Quick Start: Lightning Web Components Trailhead project. The steps include:
- Enable Dev Hub in your Org
- Install Salesforce CLI
- Install Visual Studio Code
- Install the Visual Studio Code Salesforce extensions, including the Lightning Web Components extension
-
If you haven't already done so, authorize your hub org and provide it with an alias (myhuborg in the command below):
sf org login web -d -a myhuborg
-
Clone the repositoty
forcedotcom/commerce-on-lightning-components
:git clone https://github.com/forcedotcom/commerce-on-lightning-components.git cd commerce-on-lightning-components
-
Create a scratch org and provide it with an alias (commerce-components in the command below):
sf org create scratch -f config/project-scratch-def.json -a commerce-components
-
Push the app to your scratch org:
sf project deploy start
-
Open the scratch org:
sf org open
Optional Installation Instructions
This repository contains several files that are relevant if you want to integrate modern web development tooling to your Salesforce development processes, or to your continuous integration/continuous deployment processes.
Prettier is a code formatter used to ensure consistent formatting across your code base. To use Prettier with Visual Studio Code, install this extension from the Visual Studio Code Marketplace. The .prettierignore and .prettierrc files are provided as part of this repository to control the behavior of the Prettier formatter.
ESLint is a popular JavaScript linting tool used to identify stylistic errors and erroneous constructs. To use ESLint with Visual Studio Code, install this extension from the Visual Studio Code Marketplace. The .eslintrc.cjs file is provided as part of this repository to control the behavior of the linting process in the context of Lightning Web Components development.
This repository also comes with a package.json file that makes it easy to set up a pre-commit hook that enforces code formatting and linting by running Prettier and ESLint every time you git commit
changes.
To set up the formatting and linting pre-commit hook:
- Install Node.js if you haven't already done so
- Run
npm install
in your project's root folder to install the ESLint and Prettier modules (Note: Mac users should verify that Xcode command line tools are installed before running this command.)
Prettier and ESLint will now run automatically every time you commit changes. The commit will fail if linting errors are detected. You can also run the formatting and linting from the command line using the following commands (check out package.json for the full list):
npm run lint
npm run format
The components themselves can be roughly divided into two categories. On the one hand, you will find purely presentational components for various aspects of a commerce storefront, but on the other hand, you will also find components that are designed to bridge the gap between the presentational layer and the layer that actively sets them into effect, i.e. the layer of declarative tools like the Experience Builder. These components are easily recognized by the builder prefix.
Close observers may discern that even these builder components, conceptualized as smart components, do not retrieve their data through the customary channel of one or more @wire
adapters in LWC. This is a specialty of the newer LWR experiences, which include the ones based on our B2B/B2C commerce storefront templates. Integral to these experiences are what we refer to as data providers, offering a versatile means of fetching an extensive range of data. Subsequently, this data seamlessly "flows" into components through the utilization of expressions and data binding, serving as input for @api
properties on our LWCs.
Name/FQN | Description | Application Area | Builder Support |
---|---|---|---|
c/commonButton |
Custom button control. |
* | |
c/commonLink |
Custom a[href] control with button styling. |
* | |
c/commonModal |
Custom lightning/modal that exposes two actions (primary/secondary). |
* | |
c/commonNumberInput |
Custom input[type=number] control. |
* | |
c/productAttachments |
Displays a list of links to a product's attachments. | PDP | ✅ |
c/productPricing |
Displays pricing information for products. | PDP | ✅ |
c/productPricingTiers |
Displays pricing information for products with discount tiers. | PDP | ✅ |
c/productQuantityAdd ├── c/commonButton └── c/productQuantitySelector |
Displays a c/productQuantitySelector along with an "Add to Cart" button. The Experience Builder component adds an "Add to Wishlist" button on top. |
PDP | ✅ |
c/productQuantitySelector ├── c/commonNumberInput └── c/productQuantitySelectorPopover |
Displays a c/commonNumberInput field constrained by product quantity rules (PQR) if available/configured. |
PDP | ✅ |
c/productVariantSelector |
Displays options for selecting product variations. | PDP | ✅ |
c/searchResults ├── c/commonButton ├── c/commonLink ├── c/productPricing ├── c/productQuantitySelector ├── c/searchProductCard ├── c/searchProductGrid └── c/searchPagingControl |
Displays the search results | Search/PLP | ✅ |
c/searchSortMenu |
Displays options for changing the search sort order. | Search/PLP | ✅ |
c/searchFilters ├── c/searchFiltersPanel ├── c/searchCategoryTree ├── c/searchFacet ├── c/searchInputFacet ├── c/searchSliderFacet ├── c/searchFacetItem └── c/searchFiltersModal └── c/searchFiltersModalPanel |
Displays the search filters | Search/PLP | ✅ |