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: 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 NameArgumentsDescription
    getCartFieldfieldMethod to get the fields of the cart
    setCartFieldfield, value Method to set the cart field value
    getAffectedItemIdsNAMethod to get the sObject Ids of the affected items
    getAffectedItemshierarchyLevel (optional: -1 full hierachy) Method to get all the sObject Ids of all items
    getChildItemsOfAffectedItemsnsp + 'AssetReferenceId__c'Method to get all the child line items
    setExternalPriceSample External Price argsMethod 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