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:

  1. Identify the instance of the cart document from the input map.

  2. Call the wrapper APIs using the format:, 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 NameArgumentsDescription
    getCartFieldfieldMethod to get the fields of the cart
    setCartFieldfield`, `valueMethod to set the cart field value
    getItemIdsNAMethod to get the item IDs
    getAllItems``hierarchyLevel(optional: -1 full hierachy)Method to get all the line items node
    getChildItemsnsp + 'AssetReferenceId__c'Method to get all the child line items
    createLineItem``nsp + 'ParentItemId__c' (if creating child line item)Method to create a line item
    deleteLineItemnsp + '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
    clearExternalPriceNAMethod to clear the external price
  3. 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.

  4. 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 NameArgumentsDescription
    getItemFieldfieldMethod to get an item field
    setItemFieldfield`, `valueMethod to set the value of an item field
    getItemFieldsfieldsMethod to get multiple item fields
    setItemFieldsfieldValueMapMethod to set multiple item fields
    getItemAttributesflattenedAttributeValues`, `useDisplayTextForValuesMethod to get the attribute node of the item. There are 2 parameters according to which the attribute nodes are returned.
    setItemAttributesattributeCodeToValueMapMethod to see the item attributes
    getChildItemIdsNAMethod to get the child item IDs