ccrz.ccLogicCouponApply.addCoupon

Attempts to add a coupon code to the cart, and executes the DML insert operation on the corresponding ccrz__E_CartCoupon__c record.

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

Signature

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

Inputs (Required)

This method accepts the working Map<String, Object> from the ccrz.ccLogicCouponApply.retrieveCartData method.

This method requires the following keys in the working map:

ccrz.ccApiCoupon.CART_HEADER
ccrz__E_Cart__c record to add a coupon to.
ccrz.ccApiCoupon.CART_ITEMS
List<ccrz__E_CartItem__c> of the cart items for the ccrz.ccApiCoupon.CART_HEADER.

Inputs (Optional)

If the working map includes the following key, this method evaluates it:

ccrz.ccApiCoupon.CODE
String that specifies a coupon code to add to the cart.

Logic Performed

This method passes ccrz.ccApiCoupon.CART_HEADER, ccrz.ccApiCoupon.CART_ITEMS, and ccrz.ccApiCoupon.CODE as input for the ccrz.cc_api_Cart.addCoupon public method, which completes the following actions:

  1. Evaluates the coupon code.
  2. Creates a ccrz__E_CartCoupon__c record.
  3. Executes the DML insert operation for the ccrz__E_CartCoupon__c.

Outputs

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

ccrz.ccApi.MESSAGES
List<ccrz.cc_bean_Message>, where each ccrz.cc_bean_Message contains error information sent from the server to the client. Typically, these messages are included only when ccrz.ccApi.SUCCESS is FALSE.
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