Synchronizing a Cart to an Order
This API synchronize shopping cart line items with order line items. Before you synchronize your cart add products using addMultiProducts(), add bundles using addBundle(). The API will generally be invoked when the user clicks the Place Order action from the cart.
API Details
API |
Signature |
---|---|
synchronizeCart |
|
Parameters |
||
---|---|---|
Name |
Type |
Description |
request |
|
The request data object. |
Request Data Object - CPQStruct.SynchronizeCartRequestDO |
|||
---|---|---|---|
Name |
Type |
Required? |
Description |
CartId |
|
Yes |
The Id of the cart (Product Configuration) you want to synchronize. |
API Response
Response Data Object - CPQStruct.SynchronizeCartResponseDO |
||
---|---|---|
Name |
Type |
Description |
IsSuccess |
|
Indicates whether synchronizing the cart items was successful. |
Code Sample
The following code sample enables you to synchronize cart items with an order. When the customer has finalized the cart, you can synchronize the products in the cart with the order used to generate the cart. Invoke this API after the user has finalized the cart.
public void synchronizeCart() { if(String.isNotBlank(cartId)) { // Create the request Apttus_Config2.CPQStruct.SynchronizeCartRequestDO request2 = new Apttus_Config2.CPQStruct.SynchronizeCartRequestDO(); // Add request parameters request2.CartId = cartId; // Synchronize cart Apttus_Config2.CPQStruct.SynchronizeCartResponseDO result2 = Apttus_Config2.OrderWebService.synchronizeCart(request2); } else { ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.info, 'Invalid or blank cart Id.')); } }
Request and Response XML
Example Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ord="http://soap.sforce.com/schemas/class/Apttus_Config2/OrderWebService" xmlns:cpq="http://soap.sforce.com/schemas/class/Apttus_Config2/CPQStruct"> <soapenv:Header> <ord:SessionHeader> <ord:sessionId>00D7A0000009QII!ARUAQFmpeBOmsYS2JcADxYc4PxWoOkAHJP1JiNo5vtvnDBCEvfnWWWmO7pqbEXY7WadiCmm_Vib6MjhmgUbR8321tIO1NQRg</ord:sessionId> </ord:SessionHeader> </soapenv:Header> <soapenv:Body> <ord:synchronizeCart> <ord:request> <cpq:CartId>a1I7A000001IqcfUAC</cpq:CartId> </ord:request> </ord:synchronizeCart> </soapenv:Body> </soapenv:Envelope>
Example Response
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://soap.sforce.com/schemas/class/Apttus_Config2/OrderWebService" xmlns:SynchronizeCartResponseDO="http://soap.sforce.com/schemas/class/Apttus_Config2/CPQStruct"> <soapenv:Body> <synchronizeCartResponse> <result> <SynchronizeCartResponseDO:IsSuccess>true</SynchronizeCartResponseDO:IsSuccess> </result> </synchronizeCartResponse> </soapenv:Body> </soapenv:Envelope>