Conga Product Documentation

Welcome to the new doc site. Some of your old bookmarks will no longer work. Please use the search bar to find your desired topic.

Show Page Sections

download

Adding Products to a Cart

This API adds one or more products (with default options) to the cart along with quantity, term, start date, and end date.

API

Signature

addMultiProducts

webService static Apttus_CPQApi.CPQ.AddMultiProductResponseDO addMultiProducts(Apttus_CPQApi.CPQ.AddMultiProductRequestDO request)

Parameters

Name

Type

Description

request

Apttus_CPQApi.CPQ.AddMultiProduct RequestDO

The request data object.

Request Data Object - Apttus_CPQApi.CPQ.AddMultiProductRequestDO

Field

Type

Description

CartId

ID

The Id of the cart.

SelectedProducts

List <Apttus_CPQApi.CPQ.SelectedProductDO>

The list of selected product data objects.

Note:

The SourceId, SourceFields, and CopyBundleConfigurationFromSource fields under the Data Object - Apttus_CPQApi.CPQ.SelectedProductDO are not used here. They are being used in the Request/Response XML API (CPQ API).

Data Object - Apttus_CPQApi.CPQ.SelectedProductDO

Field

Type

Description

AttributeValues

List

List of attributes values.

Comments

String

Comments associated with the record.

CopyBundleConfigurationFromSource

Boolean

You can use this to copy the configuration of the bundle from the source

CustomData

Apttus_Config2__LineItem__c

This can be used to include the list of custom fields you have added to the product.

CustomFields

List<String> CustomFields

List of custom fields created for your product.

EndDate

Date

The end date.

ProductId

ID

Id of the product bundle.

Quantity

Decimal

The bundle quantity.

RelatedLineItems

List

List of related line items for bundle

SellingTerm

Decimal

The bundle selling term.

SourceFields

List

List of the fields in the source bundle that you want to copy.

SourceId

ID

ID of the source bundle.

StartDate

Date

The start date. You should ensure you use the correct date format.

Response Data Object - Apttus_CPQApi.CPQ.AddMultiProductResponseDO

Field

Type

Description

LineNumbers

List<Decimal>

The list of line numbers added to the cart.

Code Sample

The sample below enables you to add multiple selected products with a specific product ID and its associated quantity, validity and selling term to a specific cart with a specific cartID. For example, if the user has selected software and hardware products, the products are added to the cart, on click of Add to Cart. The user is navigated to the cart page where they can view and change the quantity, selling term and other editable aspects of the product.

/**
 * The below method demonstrates how to add multiple products to an existing cart (every quote has a cart)
 * Lets assume the Quote's Cart is blank and the standalone/bundle products are Laptop, Monitor, Wifi Router
 * The input of this method is Quote Number and the Ids of the Laptop bundle product, Monitor and Wifi Router standalone products
 */
public static void addMultipleProducts(String quoteNumber, List<ID> productIds) 
{
	
	List<Apttus_Config2__ProductConfiguration__c> cart = [SELECT Id FROM Apttus_Config2__ProductConfiguration__c WHERE Apttus_QPConfig__Proposald__r.Name = :quoteNumber LIMIT 1];
	
	if(!cart.isEmpty() && productIds != null && !productIds.isEmpty()) 
	{
		
		// Assume the quantity and selling term for the product is 1
		Integer quantity = 1;
		Integer sellingTerm = 1;
		
		// Create the request object
		Apttus_CPQApi.CPQ.AddMultiProductRequestDO request = new Apttus_CPQApi.CPQ.AddMultiProductRequestDO();
		request.CartId = cart.get(0).Id;
		
		// Add the products to the request
		for(ID productId : productIds) 
		{
			Apttus_CPQApi.CPQ.SelectedProductDO selectedProduct = new Apttus_CPQApi.CPQ.SelectedProductDO();
			selectedProduct.ProductId = productId;
			selectedProduct.Quantity = quantity;
			selectedProduct.SellingTerm = sellingTerm;
			request.SelectedProducts.add(selectedProduct);
		}
		
		// Execute the addMultiProducts routine
		Apttus_CPQApi.CPQ.AddMultiProductResponseDO response = Apttus_CPQApi.CPQWebService.addMultiProducts(request);
		
		System.debug('Line Numbers of added products = ' + response.LineNumbers);
	}
}

Request/Response XML

Example Request

Expand source

<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:cpq="http://soap.sforce.com/schemas/class/Apttus_CPQApi/CPQWebService"
    xmlns:cpq1="http://soap.sforce.com/schemas/class/Apttus_CPQApi/CPQ">
    <soapenv:Header>
        <cpq:SessionHeader>
            <cpq:sessionId>00DZ000000NAEIA!ASAAQHmIRqgn4R9Oi1yQjWTIVk4UZmsDe_.eK0Z9z6qLij7Tu.L_Yo8dRA_p8OmhKMeRs4uzCZTadIgQ9fEbDKciXEQYRyaA</cpq:sessionId>
        </cpq:SessionHeader>
    </soapenv:Header>
    <soapenv:Body>
        <cpq:addMultiProducts>
            <cpq:request>
                <cpq1:CartId>a1OZ0000002YtUs</cpq1:CartId>
                <cpq1:SelectedProducts>
                    <cpq1:Comments>Some comment</cpq1:Comments>
                    <cpq1:ProductId>01tZ0000004lUXU</cpq1:ProductId>
                    <cpq1:EndDate>2020-06-30</cpq1:EndDate>
                    <cpq1:Quantity>5</cpq1:Quantity>
                    <cpq1:SellingTerm>1</cpq1:SellingTerm>
                    <cpq1:StartDate>2020-05-28</cpq1:StartDate>
                </cpq1:SelectedProducts>
                <cpq1:SelectedProducts>
                    <cpq1:Comments>some comment</cpq1:Comments>
                    <cpq1:ProductId>01tZ0000004lUXt</cpq1:ProductId>
                    <cpq1:EndDate>2020-06-30</cpq1:EndDate>
                    <cpq1:Quantity>1</cpq1:Quantity>
                    <cpq1:SellingTerm>1</cpq1:SellingTerm>
                    <cpq1:StartDate>2020-05-28</cpq1:StartDate>
                </cpq1:SelectedProducts>
                <cpq1:SelectedProducts>
                    <cpq1:Comments>Some comment</cpq1:Comments>
                    <cpq1:ProductId>01tZ0000004lUYI</cpq1:ProductId>
                    <cpq1:EndDate>2020-06-30</cpq1:EndDate>
                    <cpq1:Quantity>2</cpq1:Quantity>
                    <cpq1:SellingTerm>5</cpq1:SellingTerm>
                    <cpq1:StartDate>2020-05-28</cpq1:StartDate>
                </cpq1:SelectedProducts>
            </cpq:request>
        </cpq:addMultiProducts>
    </soapenv:Body>
</soapenv:Envelope>

Example Response

Expand source

<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns="http://soap.sforce.com/schemas/class/Apttus_CPQApi/CPQWebService"
    xmlns:AddMultiProductResponseDO="http://soap.sforce.com/schemas/class/Apttus_CPQApi/CPQ">
    <soapenv:Body>
        <addMultiProductsResponse>
            <result>
                <AddMultiProductResponseDO:LineNumbers>1</AddMultiProductResponseDO:LineNumbers>
                <AddMultiProductResponseDO:LineNumbers>2</AddMultiProductResponseDO:LineNumbers>
                <AddMultiProductResponseDO:LineNumbers>3</AddMultiProductResponseDO:LineNumbers>
            </result>
        </addMultiProductsResponse>
    </soapenv:Body>
</soapenv:Envelope>