forcedotcom / commerce-on-lightning-components

Commerce on Lightning out-of-the-box component source code for reference and educational purposes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@salesforce/commerce-components

recipes-logo

🌟 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! βœ¨πŸš€


The Hopefully Obvious

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.


Installation

Installing the components using a Scratch Org
  1. 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
  2. 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
  3. Clone the repositoty forcedotcom/commerce-on-lightning-components:

    git clone https://github.com/forcedotcom/commerce-on-lightning-components.git
    cd commerce-on-lightning-components
  4. 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
  5. Push the app to your scratch org:

    sf project deploy start
  6. 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.

Code Formatting

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.

Code Linting

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.

Pre-Commit Hook

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:

  1. Install Node.js if you haven't already done so
  2. 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

Components

Worth Knowing

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.

Overview

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 βœ…

Resources

About

Commerce on Lightning out-of-the-box component source code for reference and educational purposes

License:Apache License 2.0


Languages

Language:JavaScript 79.4%Language:HTML 11.3%Language:CSS 9.3%Language:Shell 0.0%