You are here

function commerce_discount_get_compatibility_strategy in Commerce Discount 7

Returns the compatibility strategy for the given discount.

Parameters

CommerceDiscount $discount: A Commerce Discount object with a commerce_compatibility_strategy field.

Return value

string The discount's compatibility strategy or 'any' if none is set.

1 call to commerce_discount_get_compatibility_strategy()
_commerce_discount_check_compatibility in ./commerce_discount.rules.inc
Performs a discount compatibility check for the given price field.

File

./commerce_discount.module, line 940
Defines the discount and discount offer entities, bundles and functionality.

Code

function commerce_discount_get_compatibility_strategy($discount) {
  if (isset($discount->commerce_compatibility_strategy[LANGUAGE_NONE])) {
    $strategy = $discount->commerce_compatibility_strategy[LANGUAGE_NONE][0]['value'];
  }

  // If the compatibility strategy is not set, default to 'any'.
  if (empty($strategy)) {
    $strategy = 'any';
  }

  // Note that if the field is set to an unknown value, we still return it. The
  // default condition for evaluating discount compatibility will pass through
  // unknown discount strategies, so modules that set them are responsible also
  // to evaluate them on behalf of all discounts.
  return $strategy;
}