You are here

function commerce_discount_compatibility_check in Commerce Discount 7

Rules callback: executes the "Check discount compatibility at the order level" condition.

Parameters

EntityDrupalWrapper $order_wrapper: The order the discount would be applied to.

string $discount_name: The discount name whose compatibility needs to be checked.

Return value

bool Returns TRUE if nothing has disqualified compatibility.

1 string reference to 'commerce_discount_compatibility_check'
commerce_discount_build_discount_rules in ./commerce_discount.module
Build the rules configuration for the given discounts.

File

./commerce_discount.rules.inc, line 423
Rules integration for the Commerce Discount module.

Code

function commerce_discount_compatibility_check(EntityDrupalWrapper $order_wrapper, $discount_name) {

  // Ensure the discount we're loading still exists.
  if (!($discount = entity_load_single('commerce_discount', $discount_name))) {
    return FALSE;
  }

  // Use the order total price field for order level compatibility checks.
  $order_total = $order_wrapper->commerce_order_total
    ->value();
  $return = _commerce_discount_check_compatibility($discount, $order_total);
  return $return;
}