Cart Wrapper and CartItem Wrapper for Custom Pricing Plan

Cart wrapper and CartItemWrapper interface provides minimum viable functionalities to operate on cart and cart items. Use these interfaces to add your own custom steps in the pricing plan steps.

CartItemWrapper Interface:

CartItemWrapper Interface

  1. To work with the Cart Wrapper interface:

    1. Get the cart wrapper instance for CpqCart or CpqCartDocument using the method:

      Do not use the same instance of CpqCartDocument for every pricing step. For each step, get the instance using the method mentioned below.

    2. Call the Item wrapper APIs using the wrapper.call(methodName, args).

      The Below table lists the supported methods for CpqCart

      Method NameArgumentsDescription
      CpqConstants.GET_CART_FIELDCpqConstants.FIELDMethod to get the fields of the order.
      CpqConstants.SET_CART_FIELDCpqConstants.FIELD, CpqConstants.VALUEMethod to set the order field value.
      CpqConstants.GET_SOBJECT_TYPE Method to get the SObjectType of the underlying cart.
      CpqConstants.GET_ITEM_IDS Method to get the item ids.
      CpqConstants.GET_ALL_ITEMSCpqConstants.HIERARCHY_LEVEL(optional: -1 full hierachy)Method to get all the line items.
      CpqConstants.GET_CHILD_ITEMSCpqConstants.ITEM_IDMethod to get all the child line items.
      CpqConstants.DELETE_LINE_ITEMCpqConstants.ITEM_IDMethod to delete a line item.
  2. To work with the the CartItem Wrapper interface:

    1. The line items present in the basket can be accessed using the wrapper class of CpqCartDocumentItem or CpqCartItem. Get the cart wrapper instance for CpqCart or CpqCartDocument using the method:

    2. Call the wrapper APIs using the wrapper.call(methodName, args).

      the below table lists the supported methods for CpqCart:

      Method NameArgumentsDescription
      CpqConstants.GET_ITEM_FIELDCpqConstants.FIELDMethod to get an item field, or a field from the item's related SObjects.
      CpqConstants.SET_ITEM_FIELDCpqConstants.FIELD, CpqConstants.VALUEMethod to set the value of an item field.
      CpqConstants.GET_SOBJECT_TYPE Method to get the SObjectType of the underlying cartitem.
      CpqConstants.GET_ITEM_FIELDSCpqConstants.FIELDSMethod to get multiple item fields.
      CpqConstants.SET_ITEM_FIELDSCpqConstants.FIELD_VALUE_MAPMethod to set multiple item fields.
      CpqConstants.GET_ITEM_ATTRIBUTESCpqConstants.FLATTENED_ATTRIBUTE_VALUES), CpqConstants.USE_DISPLAY_TEXT_FOR_VALUESMethod to get the attribute node of the item. There are 2 parameters according to which the attribute nodes are returned.
      CpqConstants.SET_ITEM_ATTRIBUTESCpqConstants.ATTRIBUTE_CODE_TO_VALUE_MAPMethod to set the item attributes.
      CpqConstants.GET_CHILD_ITEM_IDS Method to get the child item ids.

    Sample Code

    • The cart wrapper would internally call the V2 APIs for Digital Commerce or CPQ APIs.
    • The cart wrapper would call the V3 APIs for Standard Digital Commerce APIs.