Cart Service Tutorials
How to create a new cart
To create a new cart, you need to send a request to theHow to add custom attributes to a cart
You can define custom attributes for a cart throughmixins
.Define your custom attributes schema
First, define your custom attributes schema in the form of a JSON schema.
{
"$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 theHow to merge carts
info
To learn more about merging carts, check out Cart merging in the Carts guide.
cartId
path parameter and the anonymous cart's ID in the request body.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.
cartId
path parameter."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.
cartId
path parameter. The payload has to include the "itemType" : "EXTERNAL"
parameter, as well as the price and tax information.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.
cartId
path parameter. The payload has to include the "itemType" : "EXTERNAL"
parameter.