Download PDF
Download page Adding a Bundle to a Cart.
Adding a Bundle to a Cart
This adds a bundle along with selected products, options, and updated quantity to the cart.
API | Signature |
---|---|
addBundle | webService static Apttus_CPQApi.CPQ.AddBundleResponseDO addBundle(Apttus_CPQApi.CPQ.AddBundleRequestDO request) |
Parameters | ||
---|---|---|
Name | Type | Description |
request | Apttus_CPQApi.CPQ.AddBundleRequestDO | The id of the agreement |
Request Data Object - Apttus_CPQApi.CPQ.AddBundleRequestDO | ||
---|---|---|
Field | Type | Description |
CartId | ID | The Id of the cart. |
SelectedBundle | Apttus_CPQApi.CPQ.SelectedBundleDO | The bundle to be added to the cart. |
Data Object - Apttus_CPQApi.CPQ.SelectedBundleDO | ||
---|---|---|
Field | Type | Description |
SelectedOptions | List<Apttus_CPQApi.CPQ.SelectedOptionDO> | The list of selected option data objects. |
SelectedProduct | Apttus_CPQApi.CPQ.SelectedProductDO | The selected product data object. |
The SourceId, SourceFields, and CopyBundleConfigurationFromSource fields under the Data Object - Apttus_CPQApi.CPQ.SelectedProductDO are not used here. They are being used in the Creating an Order 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. |
Data Object - Apttus_CPQApi.CPQ.SelectedOptionDO | ||
---|---|---|
Field | Type | Description |
AttributeValues | List | List of attributes values. |
Comments | String | Comments associated with the record. |
ComponentId | ID | Id of the component. |
ComponentProductId | ID | Id of the component product. |
CustomData | Apttus_Config2__LineItem__c | The values to be set for the custom fields in the CustomFields List |
CustomFields | List<String> | List of Custom Field’s API Name |
EndDate | Date | The end date. |
Quantity | Decimal | The option quantity. |
SellingTerm | Decimal | The option selling term. |
SourceId | ID | ID of the source option. |
StartDate | Date | The start date. You should ensure you use the correct date format. |
Response Data Object - Apttus_CPQApi.CPQ.AddBundleResponseDO | ||
---|---|---|
Field | Type | Description |
LineNumber | Decimal | The bundle line number. |
Code Sample
The sample below enables you to add a bundled product with a specific product ID and its associated quantity to a specific cart with a specific cartID. For example, a user selects a bundled product-Laptop+Mouse and clicks Add to Cart, the request to add bundle to the cart is invoked and the bundle with the specific product ID is added to a cart with the cart ID.
/**
* The below method demonstrates how to add a bundle product to an existing cart (every quote has a cart)
* Lets assume the Quote's Cart is blank and Laptop is a bundle product and its two options are Keyboard and Mouse
* The input of this method is Quote Number and the Id of the Laptop bundle product
* Inside the method we will add the Laptop bundle product and also its two options Keyboard and Mouse to the cart
*/
public static void addBundle(String quoteNumber, ID bundleProductId)
{
List<Apttus_Config2__ProductConfiguration__c> cart = [SELECT Apttus_Config2__PriceListId__c,Id FROM Apttus_Config2__ProductConfiguration__c WHERE Apttus_QPConfig__Proposald__r.Name = :quoteNumber LIMIT 1];
if(!cart.isEmpty() && bundleProductId != null)
{
// Assume the quantity and selling term for the bundle product and its options is 1
Integer quantity = 1;
Integer sellingTerm = 1;
// Create the request object
Apttus_CPQApi.CPQ.AddBundleRequestDO request = new Apttus_CPQApi.CPQ.AddBundleRequestDO();
request.CartId = cart.get(0).Id;
// Add the bundle product to the request
request.SelectedBundle = new Apttus_CPQApi.CPQ.SelectedBundleDO();
request.SelectedBundle.SelectedProduct = new Apttus_CPQApi.CPQ.SelectedProductDO();
request.SelectedBundle.SelectedProduct.ProductId = bundleProductId;
request.SelectedBundle.SelectedProduct.Quantity = quantity;
request.SelectedBundle.SelectedProduct.SellingTerm = sellingTerm;
// Get all the options of the bundle product
Apttus_CPQApi.CPQ.ProductOptionGroupSearchResultDO productOptionGroupResult = Apttus_CPQApi.CPQWebService.getOptionGroupsForPriceListProduct(cart.get(0).Apttus_Config2__PriceListId__c, bundleProductId);
if(productOptionGroupResult.HasOptionGroups)
{
// Add the option products to the request
request.SelectedBundle.SelectedOptions = new List<Apttus_CPQApi.CPQ.SelectedOptionDO>();
for(Apttus_CPQApi.CPQ.ProductOptionGroupDO productOptionGroup : productOptionGroupResult.OptionGroups)
{
if(productOptionGroup.HasOptionComponents)
{
for(Apttus_CPQApi.CPQ.ProductOptionComponentDO productOptionComponent : productOptionGroup.OptionComponents)
{
Apttus_CPQApi.CPQ.SelectedOptionDO selectedOptionDO = new Apttus_CPQApi.CPQ.SelectedOptionDO();
selectedOptionDO.ComponentId = productOptionComponent.ComponentId;
selectedOptionDO.ComponentProductId = productOptionComponent.ComponentProductId;
selectedOptionDO.Quantity = quantity;
selectedOptionDO.SellingTerm = sellingTerm;
request.SelectedBundle.SelectedOptions.add(selectedOptionDO);
}
}
}
}
// Execute the addBundle routine
Apttus_CPQApi.CPQ.AddBundleResponseDO response = Apttus_CPQApi.CPQWebService.addBundle(request);
System.debug('Line Number of added bundle = ' + response.LineNumber);
}
}
Integration Details
Use the following information in your integrations with CPQ Web Services API. Refer to Integrating Conga with External Systems for information on how to get started.
API Prerequisites
Response/Request XML
Example Request
<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!ASAAQFRdZcUFQ8LrHGF_qYNN9deP0ee.07JRqgeS3IF8IIlzILBdAOPySGSkif1VBtALP6pryVNOXfhn0faHOpGsc9GFVLl0</cpq:sessionId>
</cpq:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<cpq:addBundle>
<cpq:request>
<cpq1:CartId>a1OZ0000002YdIH</cpq1:CartId>
<cpq1:SelectedBundle>
<cpq1:SelectedProduct>
<cpq1:ProductId>01tZ0000004lUXt</cpq1:ProductId>
<cpq1:Quantity>1</cpq1:Quantity>
<cpq1:SellingTerm>1</cpq1:SellingTerm>
<cpq1:StartDate>2020-05-14</cpq1:StartDate>
<cpq1:EndDate>2020-05-15</cpq1:EndDate>
<cpq1:Comments>None</cpq1:Comments>
</cpq1:SelectedProduct>
<cpq1:SelectedOptions>
<cpq1:ComponentId>a1YZ0000002jPuS</cpq1:ComponentId>
<cpq1:ComponentProductId>01tZ0000004u2io</cpq1:ComponentProductId>
<cpq1:Quantity>1</cpq1:Quantity>
<cpq1:SellingTerm>1</cpq1:SellingTerm>
<cpq1:StartDate>2020-05-14</cpq1:StartDate>
<cpq1:EndDate>2020-05-15</cpq1:EndDate>
<cpq1:Comments>none</cpq1:Comments>
</cpq1:SelectedOptions>
</cpq1:SelectedBundle>
</cpq:request>
</cpq:addBundle>
</soapenv:Body>
</soapenv:Envelope>
Example Response
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns="http://soap.sforce.com/schemas/class/Apttus_CPQApi/CPQWebService"
xmlns:AddBundleResponseDO="http://soap.sforce.com/schemas/class/Apttus_CPQApi/CPQ">
<soapenv:Body>
<addBundleResponse>
<result>
<AddBundleResponseDO:LineNumber>8</AddBundleResponseDO:LineNumber>
</result>
</addBundleResponse>
</soapenv:Body>
</soapenv:Envelope>