This API enables you to calculate the shipping amount for an entire order and does not display the breakup for each line item.

APISignature
computeShippingForCartwebService static Apttus_CPQApi.CPQ.ComputeShippingResponseDO computeShippingForCart(Apttus_CPQApi.CPQ.ComputeShippingRequestDO request)


Parameters
NameTypeDescription
requestApttus_CPQApi.CPQ.ComputeShippingRequestDOThe compute shipping request.



Request Data Object - Apttus_CPQApi.CPQ.ComputeShippingRequestDO
FieldTypeDescription
CartIDIDThe id of the cart.



Response Data Object - Apttus_CPQApi.CPQ.ComputeShippingResponseDO
FieldTypeDescription
ShippingResultsMap<ID, Apttus_Config2.CustomClass.ShippingResult>The shipping result object populated by the line item id. This is only available when called from Apex.
TotalShippingItemApttus_Config2__LineItem__cThe line item with total taxes.



Data Object - Apttus_Config2.CustomClass.ShippingResult
FieldTypeDescription
HandbackObjectAny Apex Object passed by the calling class and passed back to the calling class in the result.

Handback is used only in case when the shipping charge needs to be calculated for an object other than Cart line item e.g. Billing Schedule line items.

  • For calculating shipping charges for a cart, there is no need to pass the Handback object. It can be blank

  • For calculating the shipping charges for objects other than line items, "Item" field will be blank and the actual object will be passed as handback object to identify the object for which shipping charges are calculated.

ShippingChargeDecimalShipping amount total of all the cart line items. This is the total shipping amount for the line item. Line item is identified by the sequence in which the shipping result is added. This needs to be calculated and populated by the implementation.


Code Sample

The sample below enables you to compute shipping for a cart with a valid cartID. Using the sample below, you can compute shipping for the entire cart using the values fetched from the shipping callback class. If the shipping charge is location dependent, ensure that the account associated with the order or proposal has a valid shipping to and billing to address. For more information about Tax and Shipping scenarios refer, Updating Taxes and Shipping for an Order.
 

public void computeShippingForCart()
{
	if(String.isNotBlank(cartId))
	{
		// Start timer
		startTime = System.currentTimeMillis(); 
		
		// Create the request
		Apttus_CPQApi.CPQ.ComputeShippingRequestDO request = new Apttus_CPQApi.CPQ.ComputeShippingRequestDO();
		
		// Add request parameters
		request.CartId = cartId;
	   
		// Compute Shipping For Cart
		Apttus_CPQApi.CPQ.ComputeShippingResponseDO result = Apttus_CPQApi.CPQWebService.computeShippingForCart(request);
		 
		// End timer
		ResponseTime('computeShippingForCart');
		
		// Get Total Tax Item
		ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.info, 'Total Shipping Item : ' + result.TotalShippingItem));
		
		Map<ID, Apttus_Config2.CustomClass.ShippingResult> shippingResults = new Map<ID, Apttus_Config2.CustomClass.ShippingResult>();
		
		shippingResults = result.ShippingResults;
		
		for(Id sId : shippingResults.keySet()) {
		
			Apttus_Config2.CustomClass.ShippingResult shippingResult = shippingResults.get(sId);
			
			ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.info, 'Shipping Charges : ' + shippingResult.ShippingCharge));
		}
	}
	else 
	{
		ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.info, 'Invalid or blank cart Id.'));
	}
}
CODE