Create Cart from Basket
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.
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.
For known users, product validation rules are applied.
Run the Load API Metadata job (Vlocity CMT Administration > Cacheable API Jobs > Load API Metadata).
Run all of the jobs under the Populate API Cache window.
The CacheAPIFields custom setting must be set to true for versions prior to CME 103.1.14.
See Create Cart from Basket for additional recommendations.
For API parameter names and descriptions, see Digital Commerce REST API.
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):
Now call the API:
The response includes the order number and order ID.
You can create multiple carts with a single API call by specifying the multipleCartContext parameter in the header.
By default, pricing and basket validation are turned off when using the Create Cart API for bulk processing.
You can batch process multiple carts at one time.
You can submit an order when the cart is created.
Creating assets using the CreateCart API can only be used with a single Create Cart API call.
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:
Line Description - Description
Item Name - vlocity_cmtItemNamec
Billing Account - vlocity_cmtBillingAccountIdc
Service Account - vlocity_cmtServiceAccountIdc
Service Point - vlocity_cmtServicePointIdc
Description - Description
Order Name - Name
Order Reference Number - OrderReferenceNumber
Order Type - Type
Delivery Installation Status - vlocity_cmtDelivery_Installation_Statusc
Email - vlocity_cmtEmailc
Lead Source - vlocity_cmtLeadSourcec
Billing Account - vlocity_cmtDefaultBillingAccountIdc
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:
- Description: Description
- Quote Name: Name
- Lead Source: vlocity_cmtLeadSourcec
- Billing Account: vlocity_cmtDefaultBillingAccountIdc
- Service Account: vlocity_cmtDefaultServiceAccountIdc
- Service Point: vlocity_cmtDefaultServicePointIdc
- Description: Description
- QuoteItem Name: ItemName__c
- Billing Account: vlocity_cmtBillingAccountIdc
- Service Account: vlocity_cmtServiceAccountIdc
- Service Point: vlocity_cmtServicePointIdc
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.
|CachedQueryMode||CPQ Configuration Setup||True|
|CacheEnabled||CPQ Configuration Setup||True|
|contextKey||query parameter||contextKey from getOffers|
|UseAssetReferenceIdForParentAndRoot||CPQ Configuration Setup||True|