ccrz.ccApiCart.placeAsync

Converts a cart to a corresponding order using asynchronous Apex jobs. This method is called recursively for processing multiple, small batches of cart items. When this method is first called, it first executes synchronous logic, and then enqueues recursive calls that execute asynchronous logic. Only the synchronous logic provides return data.

Compatibility

This reference applies to:

Release Managed Package Version API Version
B2B Commerce for Visualforce Winter ’21 4.13 12

Signature

global static Map<String, Object> placeAsync(Map<String, Object>)

Service Layer Classes

Logic Service Provider
ccrz.ccLogicCartPlaceAsync

Inputs (Required)

Map<String, Object> that must include the following required keys:

ccrz.ccApi.API_VERSION
The version of the B2B Commerce for Visualforce API to reference for the method call. We recommend that you use the ccrz.ccApi.CURRENT_VERSION constant whenever possible, and only reference a specific version for compatibility if necessary.

If this key isn't specified, the method returns a ccrz.ccApi.NoApiVersionException.

Note

Include either of the following keys, but not both. If you don't include either key, the method returns a ccrz.ccApi.MissingInputException.

ccrz.ccApiCart.CART_ID
String that specifies the Salesforce ID of the cart to convert.
ccrz.ccApiCart.CART_ENCID
String that specifies the encrypted ID of the cart to convert.

Inputs (Optional)

The input map can also include the following keys:

ccrz.ccApiCart.ALLOW_PRICING_ON_ASYNC_ORDER
Boolean
Value Usage
true If the ccrz.ccApiCart.ENFORCE_PRICE_VALIDATION_ON_PLACE input is true and the cart's price data isn't current, call the ccrz.ccApiCart.priceAsync method to reprice the cart.

This behavior can cause issues with the cart's shipping and taxes, which are calculated based on the cart's previous price data, not the repriced cart. The ccrz.ccApiCart.priceAsync method doesn't update shipping or taxes. Consider creating an extension that updates shipping and tax calculations for asynchronous pricing.

Note

false (default) If the cart's price data isn't current, the cart isn't repriced, and the order placement process fails.
ccrz.ccApiCart.CARTITEMLASTID
String that specifies the Salesforce ID of the final major cart item that was processed during the previous recursive job. This ID is used only during recursive jobs that process cart items.

To determine the set of cart items in the next asynchronous job and return a consistently ordered list, the ccrz.ccLogicCartPlaceAsync.retrieveCartItems method queries major cart items with a SOQL ORDER BY Id clause.

Note

ccrz.ccApiCart.CART_PLACE_BATCH_SIZE
Integer that specifies the number of major cart items to process during each recursive job.
  • If you don't specify a value for this input, the method defaults to 200 major cart items.
  • The job also queries any minor cart items that are associated with the major cart items. As a result, the total number of processed ccrz__E_CartItem__c records is higher than the specified batch size when the cart contains complex products.

Note

ccrz.ccApiCart.ENFORCE_PRICE_VALIDATION_ON_PLACE
Boolean
Value Usage
true Evaluate whether to reprice the cart before starting the order placement process. If the cart's price data isn't current, this method doesn't create an order from the cart and returns a ccrz.cc_api_Cart.CartValidationException.

When you enable Cart Scale, this input is true by default.

Note

false (default) Don't evaluate the cart's price data before starting order placement.
ccrz.ccApiOrder.PARAM_ORDER_STATUS
String that specifies the status of the corresponding order when it's created. By default, this method sets the value Order Submitted.
ccrz.ccApiCart.PAYMENTDATA
JSON-formatted string that describes payment information passed to the ccrz.cc_hk_Payment.processPayment extension point method's ccrz.cc_hk_Payment.PARAM_TRANSACTION_DATA input.
ccrz.ccApiCart.PAYMENTRESULT
Map<String, Object> that represents the output from the ccrz.cc_hk_Payment.processPayment extension point method.
ccrz.ccApiCart.PLACE_ASYNC_FINISH
Boolean
Value Usage
true The current method execution is a recursive, asynchronous call that continues the order placement process after the initial call.
false (default) The current method execution is the synchronous portion of the initial call that begins the order placement process.
ccrz.ccApiCart.PRICING_FOR_ORDER_FAILED
Boolean
Value Usage
true An error occurred when pricing the cart during the previous iteration of the recursive, asynchronous call. The ccrz.ccLogicCartPlaceAsync.updateOrderOnError method executes.

This input is used only when the ccrz.ccApiCart.ALLOW_PRICING_ON_ASYNC_ORDER input is true and the cart was repriced because its price data wasn't current.

Note

false (default) No error occurred.
ccrz.ccApiCart.SKIP_VALID_CHECK
Boolean
Value Usage
true During this method's execution, ignore the cart's ccrz__ValidationStatus__c field and attempt to create an order from the cart.

When you pass ccrz.ccApiCart.SKIP_VALID_CHECK => true, call the ccrz.ccApiCart.price and ccrz.ccApiCart.validate methods to ensure that the cart items and prices are valid.

Important

false (default) During this method's execution, verify that the cart's ccrz__ValidationStatus__c field is set before creating an order for this cart. When this field is set, all items are valid and have a price, and the buyer is allowed to check out from the Shopping Cart page.
ccrz.ccApiCart.TRANSPAYMENTDATA
JSON-formatted string that describes payment information returned in the ccrz.cc_hk_Payment.processPayment extension point method's ccrz.cc_hk_Payment.PARAM_TRANSACTION_PROCESSED_DATA output.
  • Create the payment information on the cart before you call this method, and then associate the payment information with the order after this method completes.
  • If you specify both ccrz.ccApiCart.PAYMENTDATA and ccrz.ccApiCart.TRANSPAYMENTDATA and these keys describe a stored payment, this method creates a corresponding ccrz__E_StoredPayment__c record.
  • If you specify ccrz.ccApiCart.PAYMENTDATA, ccrz.ccApiCart.TRANSPAYMENTDATA, and ccrz.ccApiCart.PAYMENTRESULT, this method creates a corresponding ccrz__E_TransactionPayment__c record.

Note

Outputs

Map<String, Object> that can include the following keys:

Only the initial synchronous ccrz.ccApiCart.placeAsync method call includes return data. The return data for subsequent asynchronous Apex jobs isn't accessible.

Note

ccrz.ccApi.API_VERSION
Integer that indicates which API version was used for the query.
ccrz.ccApi.SUCCESS
Boolean
Value Usage
true The call completed.
false The call encountered errors.

B2B Commerce for Visualforce doesn't always return an exception for any errors that can occur. When this value is false, consider rolling back the API transaction to a previous savepoint.

Tip

ccrz.ccApiCart.ORDER_ID
String that specifies the Salesforce ID of the created ccrz__E_Order__c.