createCart()

This creates a cart for the order referenced by OrderId.

API Details



Parameters
NameTypeDescription
requestCPQStruct.CreateCartRequestDOThe request data object.



Request Data Object - CPQStruct.CreateCartRequestDO
FieldTypeRequired?Description
OrderIdIDYesThe Id of the order to be associated with the cart.
PropertiesList<Config2.Property>NoThe list of properties applicable to the cart.



Data Object - Config2.Property
FieldTypeRequired?Description
NameStringYesSpecify the features applicable to the cart. Applicable values are:
  • useAdvancedApproval: Enables Advanced Approval for a cart.
  • useDealOptimizer: Enables Deal Optimizer for a cart.
ValueStringNoThe applicable values are true or false. Specifying the value as true enables the feature for a cart.


API Response

Response Data Object - CPQStruct.CreateCartResponseDO
FieldTypeDescription
CartIdIDThe Id of the newly created cart object.



Code Sample

The following code sample enables you to create a cart for a valid order with an Order Id. Using the sample, you can search for a valid order using an order number. If an order exists with the order number entered, you can create a cart using createCart(). You can invoke this API in use cases when you want to show a cart page based on the order. 


 public void createCart()
{
	if(String.isNotBlank(orderId))
	{
		// Create config properties
		List<Apttus_Config2.Property> configProps = new List<Apttus_Config2.Property>();
		
		Apttus_Config2.Property prop = new Apttus_Config2.Property();
		
		prop.Name = 'useAdvancedApproval';
		prop.Value = 'false';
		configProps.add(prop);
		
		prop = new Apttus_Config2.Property();
		prop.Name = 'useDealOptimizer';
		prop.Value = 'false';
		configProps.add(prop);
		
		// Create the request
		Apttus_Config2.CPQStruct.CreateCartRequestDO request = new Apttus_Config2.CPQStruct.CreateCartRequestDO();
		
		// Add request parameters
		request.OrderId = orderId;
		request.Properties.addAll(configProps);
   
		// Create a new cart for Order
		Apttus_Config2.CPQStruct.CreateCartResponseDO result = Apttus_Config2.OrderWebService.createCart(request);
		
		// Get the cart Id
		cartId = result.CartId;
	} else {
		ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.info, 'Invalid or Blank Order Id.'));
	}
}
CODE