Skip to main content
The Shopping Cart add-on manages the customer’s active cart and its line items through the commerce journey. It supports cart persistence, quantity changes, discounts, cart summaries, and extension hooks used by compatible modules.

Key Features

  • Add and remove products from a cart.
  • Adjust item quantities.
  • Persist carts across customer sessions.
  • Apply cart discounts according to configured rules.
  • Extend cart operations through the supplied hook system.
  • Save a cart for later and review the cart summary.

Package Structure

How It Works

  1. A customer adds a product or variation to the cart.
  2. The cart service validates the item and requested quantity.
  3. Customers can update quantities or remove items.
  4. The cart summary reflects the current items and applicable discounts.
  5. Cart data is retained according to the configured persistence behaviour.
  6. The hook system allows compatible modules to extend cart events.

Components

  • ShoppingCartHook.ts provides cart hook logic and extension points.
  • Models represent carts and cart items.
  • Controllers expose cart endpoints.
  • Repositories and services implement cart data access and operations.
  • Migrations create the required database structures.

Configuration

Configure the following settings after the add-on has been discovered and enabled. Only apply settings supported by the supplied package version.
  • Configure cart persistence behaviour in the Admin application.
  • Review discount eligibility and application rules.
  • Set save-for-later behaviour where available.
  • Review the hook extension points used by other installed add-ons.

Installation (Pre-built Premium Add-on)

This add-on is delivered as a pre-built JavaScript package by SpurtCommerce. Install the supplied compiled files; you do not need to run a TypeScript build.

Before you begin

  • Confirm that the add-on package is intended for the SpurtCommerce version and edition installed in your project.
  • Back up the application files and database before installing a new add-on or applying its migrations.
  • Extract the supplied add-on archive. The package normally contains index.js (which exports the spurtcommerceAddon manifest), compiled folders such as controllers/, models/, repositories/, services/, migrations/, and may include an optional hook file and package.json.
  • Work from the SpurtCommerce project root - the directory containing the application’s main.js and package.json.

Step 1: Place the add-on in add-ons/

Create an add-ons/ directory in the project root if it does not already exist. Copy the supplied add-on folder into it. Use the folder name provided with the add-on package and retain the supplied internal file structure. There are two supported layouts. Layout A - compiled files directly inside the add-on folder
Layout B - keep the dist/ directory inside the add-on folder
For Layout B, the add-on folder must contain a root-level package.json that points to the compiled entry file. For example:
Alternatively, create add-ons/<addon-name>/index.js with this content:
Important: The add-on registry does not discover a nested dist/ directory as a package entry by itself. When retaining dist/, provide the root-level package.json or index.js entry point shown above.

Step 2: Add add-on-specific environment settings

Check the add-on’s configuration section and the README or handover notes included with the supplied package. If the add-on requires environment variables - for example, a Redis connection, socket port, payment gateway credentials, or an external service key - add the exact variables to the SpurtCommerce project’s .env file. Do not add placeholder values to production. Keep credentials private and do not commit real secrets to source control. If the add-on does not specify additional environment variables, no add-on-specific .env change is required.

Step 3: Install only additional dependencies required by the add-on

The SpurtCommerce application already provides its core dependencies, such as TypeORM, routing-controllers, and typedi. Install an additional third-party package only when it is explicitly listed as a requirement in the supplied add-on documentation or package manifest. Run any required command from the project root:
Do not reinstall the SpurtCommerce core dependencies or run a build for the pre-built add-on. The package handover notes should identify any additional dependency that is required.

Step 4: Start or restart SpurtCommerce

Start the application using the normal command for your project. For example:
or:
If the server is already running, restart it after copying the add-on files or changing .env values. No manual edits to main.js or SpurtCommerce core loader files are required when the project has the supported add-on registry.

Step 5: Allow the core loaders to register the add-on

During startup, SpurtCommerce performs the add-on integration through its loader lifecycle:
  1. Discovery (addonRegistry): Scans the add-ons/ directory, loads the add-on entry file, and validates/caches its spurtcommerceAddon manifest.
  2. Database and migrations (typeormLoader): Registers the add-on’s TypeORM entities and migrations, runs the migrations, seeds the add-on’s plugin record where defined, and calls manifest.initialize(dataSource) when provided.
  3. Plugin registration (pluginLoader): Registers the add-on’s pluginName in the application’s plugin module.
  4. API routes (expressLoader): Mounts the add-on’s store, vendor, and admin controllers under the /api/* route space.
  5. Hooks (HookUtil): Registers the event hooks included with the add-on so relevant core events can invoke them.
This is performed by the host application at startup. Do not manually run the add-on migrations or register controllers/entities in core files unless the add-on’s own handover guide specifically requires an exception.

Step 6: Verify add-on discovery and activation

After startup, check the application console for a discovery message similar to:
Then verify that the plugin record is enabled. You can check the Plugins area in the Admin application or query the database:
Confirm that plugin_status is 1. If the add-on is disabled, enable it through the Admin application where supported, or follow your platform’s plugin administration procedure. Finally, test the add-on’s documented API routes and its corresponding Admin, Vendor, or Store workflow. Test in a development or staging environment before enabling the add-on for production users.

Installation troubleshooting

Version and delivery note: Premium add-ons are supplied as compiled packages for a compatible SpurtCommerce release. Use the package delivered for your project version. Do not substitute source-build instructions, rename internal files, or mix compiled packages from different releases unless SpurtCommerce confirms compatibility.

Operational Notes

Test cart updates with products, variants, stock limits, and discounts. Confirm that totals are recalculated correctly after item quantity or pricing changes.

Summary

The Shopping Cart add-on extends SpurtCommerce with the capabilities described above. It is delivered as a compiled premium package and is loaded by the SpurtCommerce add-on registry when installed according to the steps above.

API Endpoints

The endpoint definitions below are derived from the supplied controller files. All routes are mounted under the SpurtCommerce /api prefix. Each entry describes the operation and lists the path, query, body, or file inputs identified by the controller annotations. Controller routes documented: 23.

Store API

StoreShoppingCartController

POST /api/store-shopping-cart

Definition: Creates store shooping cart. Inputs Request model: CreateShoppingCartRequest is used by the controller for payload validation. Authorization: The controller applies the customer access context and the following permission scope: create-shopping-list.

PUT /api/store-shopping-cart/:id

Definition: Updates store shooping cart. Inputs Request model: CreateShoppingCartRequest is used by the controller for payload validation. Authorization: The controller applies the customer access context and the following permission scope: create-shopping-list.

GET /api/store-shopping-cart/list

Definition: Retrieves the store shooping cart. Inputs Authorization: The controller applies the customer access context and the following permission scope: view-shopping-list.

GET /api/store-shopping-cart

Definition: Retrieves the store shooping cart list. Inputs Authorization: The controller applies the customer access context and the following permission scope: view-shopping-list.

GET /api/store-shopping-cart/:id/detail

Definition: Retrieves the store shooping cart detail. Inputs Authorization: The controller applies the customer access context and the following permission scope: view-shopping-list-line-item.

DELETE /api/store-shopping-cart/:id

Definition: Deletes the selected shopping list group identified by the supplied shopping cart ID. Inputs Authorization: The controller applies the customer access context and the following permission scope: delete-shopping-list.

StoreShoppingCartDetailController

POST /api/store-shopping-cart-detail

Definition: Creates and update shopping cart detail. Inputs Request model: CreateShoppingCartDetailsRequest is used by the controller for payload validation. Authorization: The controller applies the customer access context and the following permission scope: edit-shopping-list-line-item.

POST /api/store-shopping-cart-detail/delete

Definition: Deletes shopping cart detail. Inputs Authorization: The controller applies the customer access context and the following permission scope: delete-shopping-list-line-item.

Vendor API

VendorShoppingCartController

GET /api/vendor-shopping-cart

Definition: Retrieves the vendor shopping cart list. Inputs Authorization: The controller applies the vendor access context and the following permission scope: list-shopping-list.

POST /api/vendor-shopping-cart

Definition: Creates and update shopping cart detail. Inputs Request model: CreateShoppingCartDetailRequest is used by the controller for payload validation. Authorization: The controller applies the vendor access context and the following permission scope: edit-shopping-list.

POST /api/vendor-shopping-cart/create-duplicate

Definition: Creates duplicate Shopping Cart. Inputs Authorization: The controller applies the vendor access context and the following permission scope: duplicate-shopping-list.

GET /api/vendor-shopping-cart/:id/detail

Definition: Retrieves the store shooping cart detail. Inputs Authorization: The controller applies the vendor access context and the following permission scope: list-shopping-list.

GET /api/vendor-shopping-cart/:id/product-list

Definition: Retrieves the store shoping cart product list. Inputs Authorization: The controller applies the vendor access context and the following permission scope: list-shopping-list.

POST /api/vendor-shopping-cart/delete

Definition: Deletes shopping cart detail. Inputs Request model: DeleteShoppingCartIdValidatorRequest is used by the controller for payload validation. Headers: The controller documentation lists Authorization.

PUT /api/vendor-shopping-cart/:id

Definition: Updates the status of the selected record using the submitted status value. Inputs Authorization: The controller applies the vendor access context and the following permission scope: edit-shopping-list.

VendorShoppingCartDashboardController

GET /api/vendor-dashboard-shopping-cart/reports/repeated-products

Definition: Retrieves the vendor shopping cart repeated-products. Authorization: The controller applies the vendor access context.

GET /api/vendor-dashboard-shopping-cart/reports/repeated-customers

Definition: Retrieves the vendor shopping cart repeated-customers. Authorization: The controller applies the vendor access context.

GET /api/vendor-dashboard-shopping-cart/new

Definition: Retrieves the vendor shopping cart shopping list. Authorization: The controller applies the vendor access context.

GET /api/vendor-dashboard-shopping-cart/orders/conversions

Definition: Retrieves the vendor shopping cart order count. Authorization: The controller applies the vendor access context.

GET /api/vendor-dashboard-shopping-cart/revenue/total

Definition: Retrieves the vendor shopping cart revenue total. Inputs Authorization: The controller applies the vendor access context.

GET /api/vendor-dashboard-shopping-cart/chart-data

Definition: Retrieves the vendor shopping cart shopping list chart-data. Inputs Authorization: The controller applies the vendor access context.

GET /api/vendor-dashboard-shopping-cart/customers/new

Definition: Retrieves the vendor shopping cart shopping list new customer data. Inputs Authorization: The controller applies the vendor access context.

GET /api/vendor-dashboard-shopping-cart/products/trending

Definition: Retrieves the vendor shopping cart top trending products. Inputs Authorization: The controller applies the vendor access context.