Cart Service Tutorials

How to create a new cart

To create a new cart, you need to send a request to the Creating a new cart endpoint.
Loading...

How to add custom attributes to a cart

You can define custom attributes for a cart through mixins.

Define your custom attributes schema

First, define your custom attributes schema in the form of a JSON schema.

Copy
Copied
{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
      "cartInstructions": {
        "type": "object",
        "properties": {
          "instruction": {
            "type": "string"
          }
        }
      }
    }
}

Upload your schema to a hosting service and save its URL

Update a cart with custom attributes

To add custom attributes to a cart, you need to send a request to the Updating a cart endpoint.
Loading...

How to merge carts

info

To learn more about merging carts, check out Cart merging in the Carts guide.

To merge an anonymous cart with a customer cart, you need to send a request to the Merging carts endpoint. Provide the customer cart's ID in the cartId path parameter and the anonymous cart's ID in the request body.
Loading...

How to source pricing information from an external price calculation tool

For B2B scenarios, you might want to integrate an external application for price calculation for your products. Usually, the systems, such as ERPs, store all the relevant customer-specific pricing information needed for customer-specific pricing.
The external system then can communicate with the Cart Service directly to overwrite the price of the product added to the cart.

info

To achieve the communication between Commerce Engine and the external pricing tool, you have to configure both systems accordingly. The steps required for such a case are described in the External Products, Pricing and Fees documentation. You need to generate a dedicated scope that serves as the authorization token for the API calls.

After enabling the external application to update carts with calculated prices, to add a product that is available within Commerce Engine, but with an external price, you need to send the request to the Adding a product to cart endpoint. Provide the customer cart's ID in the cartId path parameter.
Loading...
Notice the "itemType": "EXTERNAL" definition which allows the Cart Service to overwrite the pricing from Commerce Engine. The payload must include the price and tax information.
warning

When you have enabled external pricing, it's essential to ensure the accuracy of the prices, as CE does not perform price validation in these instances.

How to add a product from an external source to a cart

For some cases, you might want to allow adding products from an external system to cart, and not only from your online store. The products from external product management sources can be added directly to the customer's cart, bypassing the standard product catalog.

info

To achieve the communication between Commerce Engine and the external product management tool, you have to configure both systems accordingly. The steps required for such a case are described in the External Products, Pricing and Fees documentation. You need to generate a dedicated scope that serves as the authorization token for the API calls.

To add a product outside Commerce Engine, you need to send the request to the Adding a product to cart endpoint. Provide the customer cart's ID in the cartId path parameter. The payload has to include the "itemType" : "EXTERNAL" parameter, as well as the price and tax information.
Loading...

How to add an external fee

For some cases, you might need to calculate and charge additional fees, for example for packaging, freight, or any additional reasons. The fees calculated externally can be added directly to the customer's cart.

info

To achieve the communication between Commerce Engine and the fee management tool, you have to configure both systems accordingly. The steps required for such a case are described in the External Products, Pricing and Fees documentation. You need to generate a dedicated scope that serves as the authorization token for the API calls.

To add a custom fee to the cart, you need to send the request to the Adding a product to cart endpoint. Provide the customer cart's ID in the cartId path parameter. The payload has to include the "itemType" : "EXTERNAL" parameter.
Loading...