You are here

function commerce_coupon_evaluate_conditions in Commerce Coupon 7.2

Run the condition component for a coupon.

Parameters

EntityDrupalWrapper $coupon_wrapper: A wrapped coupon entity.

EntityDrupalWrapper $order_wrapper: The wrapped order entity that the coupon belongs to.

array $data: An array of extra information to pass into the coupon conditions.

Return value

bool Whether or not the conditions pass.

2 calls to commerce_coupon_evaluate_conditions()
commerce_coupon_discount_extract_coupons in ./commerce_coupon.rules.inc
Fetches the coupons related to a discount from an order.
commerce_coupon_redeem_coupon_code in ./commerce_coupon.module
Apply a coupon to an order and return success or failure.

File

./commerce_coupon.module, line 859
Provides coupon functionality for Drupal Commerce.

Code

function commerce_coupon_evaluate_conditions(EntityDrupalWrapper $coupon_wrapper, EntityDrupalWrapper $order_wrapper, $data = array()) {
  $outcome = rules_invoke_component('coupon_type_' . $coupon_wrapper->type
    ->value() . '_conditions', $coupon_wrapper, $order_wrapper, $data);
  $context = array(
    'coupon' => $coupon_wrapper,
    'order' => $order_wrapper,
    'data' => $data,
  );

  // Allow other modules to alter the outcome.
  drupal_alter('commerce_coupon_condition_outcome', $outcome, $context);
  return $outcome;
}