Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

ccrz.ccLogicOrderSplitOrder.prepareSplits

Splits order items into a map that describes the split criteria, and builds a map of seller IDs and seller representative users.

Compatibility

This reference applies to:

Release Managed Package Version API Version
B2B Commerce for Visualforce Winter ’21 4.13 12
B2B Commerce for Visualforce Spring ’20 4.12 11
B2B Commerce for Visualforce Summer ’19 4.11 10
B2B Commerce for Visualforce Spring ’19 4.10 9
B2B Commerce for Visualforce Summer ’18 4.9 8

Signature

global virtual Map<String, Object> prepareSplits(Map<String, Object>)

Inputs (Required)

This method accepts the working Map<String, Object> after the ccrz.ccLogicOrderSplitOrder.retrieveOrderData method completes.

This method requires the following keys in the working map:

ccrz.ccApiOrder.ORDERITEMSBYID
Map<String, List<ccrz__E_OrderItem__c>> of the original order's items, keyed by parent ccrz__E_Order__c.
ccrz.ccApiOrder.ORDERLIST
List<ccrz__E_Order__c> of the original orders to split.

Logic Performed

This method completes the following actions:

  1. Evaluates each order and builds ccrz.ccApiOrder.SPLORDITM, which is a map of maps, where:
    • The outer map's key is the original order ID.
    • Each inner map's key is the criteria for splitting ccrz.ccApiOrder.ORDERITEMSBYID, such as the ID of the referenced ccrz__E_Seller__c from each ccrz__E_OrderItem__c record's ccrz__Seller__c field.
    • Each inner map's value is the list of corresponding ccrz__E_OrderItem__c data.

    Consider the following example, where:

    • Original Order A contains two order items: one order item from Seller X and another order item from Seller Y.
    • Original Order B contains three order items: two order items from Seller X and another order item from Seller Y.

    The resulting ccrz.ccApiOrder.SPLORDITM map resembles the following serialized JSON:

    {
        "Order A" : {
            "Seller X" : [Order Item 1],
            "Seller Y" : [Order Item 2]
        },
        "Order B" : {
            "Seller X" : [Order Item 3,Order Item 4],
            "Seller Y" : [Order Item 5]
        }
    }
  2. Passes the seller IDs associated the order items as input for the ccrz.ccApiSeller.fetch method.
  3. Evaluates the ccrz.ccApiSeller.SELLERLIST output from ccrz.ccApiSeller.fetch and adds each seller's ID and ccrz__DefaultRep__c user to ccrz.ccApiOrder.OWNERPERSPLT, a map for other downstream methods to evaluate.

Outputs

This method returns the working Map<String, Object>, and sets the following keys:

ccrz.ccApiOrder.OWNERPERSPLT
Map<String, String> that associates each seller ID to its ccrz__DefaultRep__c user.
ccrz.ccApiOrder.SPLORDITM
Map<String, Map<String, List<ccrz__E_OrderItem__c>>> of the split order items, keyed first by order ID and then by split criteria, such as seller ID.