The Create Cart API provides the ability to create a cart after items have been added to a basket. The API provides the ability to convert the basket into a corresponding order and order line item.
1POST /v3/carts
First, offers are configured without a cart, then this API is called to add the basket contents to the cart (order and order line items) before submitting. The API creates a new cart. The API will validate and price the cart after adding the items and returns a link to the full cart contents.
Beginning with the Summer 2019 release, the CacheAPI.CreateCartFromContextKey configuration setting can be used to determine the behavior of the Create Cart API. If set to true, the Create Cart API uses the cartContextKey passed in the input to create the cart. If set to false or not specified, the JSON result from the Basket API must be passed in the request body of the Create Cart API to create the cart. The API requires the user account, catalog code, and cartItems in the body of the request.
You can create multiple carts with a single Create Cart API call. See Create Cart from Basket for an example.
You can batch process multiple carts at one time. See Create Cart from Basket for an example.
You can submit an order when the cart is created. See Create Cart from Basket for an example.
You can pass additional order capture information when creating an order from a basket. See Create Cart from Basket for an example.
First, create a basket. To create a basket, first run the Basket API. Then, use the output of the Basket API as input for the Cart API. Be sure to add the catalogCode and accountId parameters.
The body should resemble the following (note that JSONResult has been truncated for clarity):
You can pass additional order capture information when creating an order from a basket. After a Basket has been created, and the user is ready to check out, you can pass additional information in the order header and order Line Items. For example, you might want to pass an updated billing address or an external Order Management system ID.
To prevent inadvertently updating a field that may invalidate ancillary operations, by default, the Create Cart API is restricted to updating only the following Order and OrderItem fields:
Order Item:
Line Description - Description
Item Name - vlocity_cmtItemNamec
Billing Account - vlocity_cmtBillingAccountIdc
Service Account - vlocity_cmtServiceAccountIdc
Service Point - vlocity_cmtServicePointIdc
Order:
Description - Description
Order Name - Name
Order Reference Number - OrderReferenceNumber
Order Type - Type
Delivery Installation Status - vlocity_cmtDelivery_Installation_Statusc
Service Account - vlocity_cmtDefaultServiceAccountIdc
Service Point - vlocity_cmtDefaultServicePointIdc
To update any fields other than the fields in the preceding list, you can create a fieldset on Orders for Order field updates and OrderProducts for OrderItem field updates. The fieldset name and label should match CartAllowedFieldSet for both Orders and OrderProducts.
By default, the Create Cart API is restricted to updating only the following Quote and QuoteItem fields:
Service Account: vlocity_cmtDefaultServiceAccountIdc
Service Point: vlocity_cmtDefaultServicePointIdc
QuoteItem:
Description: Description
QuoteItem Name: ItemName__c
Billing Account: vlocity_cmtBillingAccountIdc
Service Account: vlocity_cmtServiceAccountIdc
Service Point: vlocity_cmtServicePointIdc
Custom Settings and Query Parameter Recommendations
The following settings are recommended to increase performance when using the Create Cart API. These settings are appropriate when creating either single or multiple carts.