ccrz.ccLogicCartPlaceAsync.createOrderItem
Creates a ccrz__E_OrderItem__c record by copying
all relevant field values from a source ccrz__E_CartItem__c
record. This method also evaluates the source cart item's groups and subscriptions, and sorts
the order item by whether it's a major or minor line item. The ccrz.ccLogicCartPlaceAsync.processCartItems method calls this method for each
ccrz__E_CartItem__c associated with the source
cart.
Compatibility
This reference applies to:
Release | Managed Package Version | API Version |
---|---|---|
B2B Commerce for Visualforce Winter ’21 | 4.13 | 12 |
Signature
global virtual Map<String, Object> createOrderItem(Map<String, Object>)
Inputs (Required)
This method accepts the working Map<String, Object> from the ccrz.ccLogicCartPlaceAsync.processCartItems method.
This method requires the following keys in the working map:
- 'cartItemToCreate'
- ccrz__E_CartItem__c record to create an ccrz__E_OrderItem__c from.
- 'hasCurrencyIsoCode'
- Boolean
Value Usage true The org supports multiple currencies, which indicates that the created ccrz__E_OrderItem__c must specify a value for the currencyIsoCode field. false (default) The storefront supports only one currency. - 'majorOrderItemMap'
-
Map<String, ccrz__E_OrderItem__c>, where:
- Each key is the Salesforce ID of a source ccrz__E_CartItem__c record that represents a major line item in the cart.
- Each value is the ccrz__E_OrderItem__c to create for the corresponding major line item in the order.
- 'minorOrderItemMap'
-
Map<String, List<ccrz__E_OrderItem__c>>, where:
- Each key is the Salesforce ID of a source ccrz__E_CartItem__c record that represents a major line item in the cart.
- Each value is a List<ccrz__E_OrderItem__c> to create as minor line items for the ccrz__E_OrderItem__c that corresponds to the major line item from the cart.
- 'workingMap'
- Map<String, Object> that was passed to the ccrz.ccLogicCartPlaceAsync.processCartItems method and then to this method.
Logic Performed
This method completes the following actions:
- Creates an ccrz__E_OrderItem__c from the source ccrz__E_CartItem__c record.
- Evaluates whether the source ccrz__E_CartItem__c has an associated ccrz__E_SubProdTerm__c.
- Evaluates the order item's ccrz__OrderLineType__c
and sorts the item into an appropriate map:
- If the order item is a major line item or coupon, the method adds the order item to the map of major items.
- Otherwise, the method adds the order item to the map of minor items.
- Evaluates whether the cart item belonged to any ccrz__E_CartItemGroup__c records, and
processes the group information:
- Associates the ccrz__E_CartItem__c with the appropriate ccrz__E_OrderItemGroup__c in the 'orderIGroupsToAdd' key in the working map.
- Associates the source ccrz__E_CartItemGroup__c with the list of created ccrz__E_OrderItem__c records in the 'cartGroupToOrderItems' key in the working map.
Outputs
This method returns the working Map<String, Object>, and sets the following key:
- 'hasSubProdTerm'
- Boolean
Value Usage true The source ccrz__E_CartItem__c had an associated ccrz__E_SubProdTerm__c record. false The source ccrz__E_CartItem__c didn't have subscription data.