You are here:
SplitProductInterface
SplitProductInterface enables customers to split one line item into multiple lines. When a line item—either a single line item or a bundle—has a quantity greater than one, you can clone the line item into multiple individual lines to customize them.
Type
Loosely typed
Triggered When
Taking the split action in the cart triggers the SplitProductInterface.
Called In
The following is the SplitProductInterface data flow:
-
LineItemManagementController and Ω
-
ProductLineItemActionParam
Split action
-
ProductLineItemEventHandler
-
SplitProductInterface
-
invokeMethod
-
Success or failure
NotePricing is not called.
Signature
Access |
Signature |
|---|---|
global |
|
Default Implementation
The DefaultSplitProductImplementation splits or copies a line item and its children with a quantity greater than one when the user must separately configure each line item. It gets the line number and the quantity of the line to be split. It gets the children of the line item if any. It sets the quantity of the original line number to one. It gets the next line numbers to use for copies. It clones the line and its children in a loop, adding the correct line numbers. At the end, it inserts all new lines.
Other Implementations
None
Input Parameters
methodName
Required
Type: String
The name of the method to execute, for example, SplitProduct
inputMap
Required
Type: Map<String, Object>
The inputMap includes the following:
-
parentId
Type: Id
The opportunity, order, or quote ID
-
lineitemId
Type: Id
The opportunity, order, or quote line item ID
Output Parameters
outputMap
Type: Map<String, Object>
Not currently used
optionsMap
Type: Map<String, Object>
Not currently used
Sample Implementation
OrderItem oi =[select id,orderId from OrderItem where id='8021x00000132lX'];
// replace with any valid OrderItem Id, can also be used for OpportunityItems or QuoteLineItems
vlocity_cmt.ProductLineItemActionParam productLineItemActionParam = new vlocity_cmt.ProductLineItemActionParam();
productLineItemActionParam.action = 'Split';
productLineItemActionParam.parentId = oi.OrderId;
productLineItemActionParam.lineItemId = oi.id;
Map<String,Object> itemInfoMap = new Map<String,Object>();
/**
This sample array shows an example of the number of quantities to split by.
For an item with Quantity 6, this splitNumbers array will split the line item into 3 line items with
quantities 3, 2, and 1. An empty itemInfoMap means split equally with quantity 1.
List<Integer> splitArray = new List<Integer>();
splitArray.add(3);
splitArray.add(2);
splitArray.add(1);
itemInfoMap.put('splitNumbers', splitArray);
**/
productLineItemActionParam.itemInfoMap = itemInfoMap;
Map<String,Object> inputMap = new Map<String,Object>();
inputMap.put('SplitProduct', productLineItemActionParam);
system.debug('inputMap: '+inputMap);
Map<String,Object> outputMap = new Map<String,Object>();
Map<String,Object> optionsMap = new Map<String,Object>();
vlocity_cmt.DefaultSplitProductImplementation split = new vlocity_cmt.DefaultSplitProductImplementation();
split.invokeMethod('SplitProduct',inputMap,outputMap,optionsMap);
System.debug('outputMap: ' + outputMap);

