Use Cart Documents
Cart documents are trimmed and flexible JSON structures that you can use in the CPQ on Core services. You can then use the output JSON to send responses to upper layer APIs such as the Digital Commerce APIs.
To use a cart document:
-
Identify the instance of the cart document from the input map.
-
Call the wrapper APIs using the format:
CpqCartDocument.call(methodName, args)
The results of all of these methods are in JSON format, with a single key-value pair: "result": value. Set methods (setCartField, setExternalprice) require arguments without “result” node.Method Name Arguments Description getCartField
field
Method to get the fields of the cart setCartField
field`, `value
Method to set the cart field value getItemIds
NA Method to get the item IDs getAllItems
``hierarchyLevel (optional: -1 full hierachy)
Method to get all the line items node getChildItems
nsp
+
'AssetReferenceId__c'
Method to get all the child line items createLineItem
``nsp (if creating child line item)
Method to create a line item deleteLineItem
nsp
+
'AssetReferenceId__c'
Method to delete a line item setExternalPrice
{"itemFieldsInfo":{"58f1a32b-a0f9-4455-9e53-dcd4dd839bb0":{"vlocity_digital__OneTimeCharge__c":{"value":100,"detail":"Priced from AttributePricingProcedure","source":"ABP","code":"OT_STD_PRC"},"vlocity_digital__RecurringCharge__c":{"value":50,"detail":"Priced from AttributePricingProcedure","source":"ABP","code":"REC_MNTH_STD_PRC"}},"57d29a96-59c0-49b9-b4f8-a61f5d51a7ef":{"vlocity_digital__OneTimeCharge__c":{"value":70,"detail":"Priced from AttributePricingProcedure","source":"ABP","code":"OT_STD_PRC"},"vlocity_digital__RecurringCharge__c":{"value":80,"detail":"Priced from AttributePricingProcedure","source":"ABP","code":"REC_MNTH_STD_PRC"}}},"timePlanPolicyList":[{"ID":"57d29a96-59c0-49b9-b4f8-a61f5d51a7ef","TimePolicyName":"Purchase Date To End Of Plan Duration","TimePlanName":"12 Months Time Plan"},{"ID":"58f1a32b-a0f9-4455-9e53-dcd4dd839bb0","TimePolicyName":"Purchase Date To End Of Plan Duration","TimePlanName":"6 Months Time Plan"}]}
Method to set the external price clearExternalPrice
NA Method to clear the external price -
If you've extended or modified the pricing plan helper in your org, then update the existing class based on the new version of the pricing plan helper.
-
Access the line items in the basket using the CpqCartDocumentItem wrapper class.
Use these methods to get and set fields on line items. The results of all of these methods are in JSON format, with a single key-value pair: "result": value. Set methods (setItemField, setItemFields, setItemAttributes) require arguments without “result” node.
Method Name Arguments Description getItemField
field
Method to get an item field setItemField
field`, `value
Method to set the value of an item field getItemFields
fields
Method to get multiple item fields setItemFields
fieldValueMap
Method to set multiple item fields getItemAttributes
flattenedAttributeValues`, `useDisplayTextForValues
Method to get the attribute node of the item. There are 2 parameters according to which the attribute nodes are returned. setItemAttributes
attributeCodeToValueMap
Method to see the item attributes getChildItemIds
NA Method to get the child item IDs