You are here

function commerce_discount_get_compatibility_selection in Commerce Discount 7

Returns the compatibility selection for the given discount.

Parameters

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

Return value

int[] An array of discount IDs selected for the discount's compatibility strategy or an empty array if none are selected (or a non-array value is found).

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

File

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

Code

function commerce_discount_get_compatibility_selection($discount) {

  // Don't use the entity_metadata_wrapper here on purpose for performance
  // reasons.
  $items = field_get_items('commerce_discount', $discount, 'commerce_compatibility_selection', LANGUAGE_NONE);
  $selection = array();
  if (!$items) {
    return $selection;
  }
  foreach ($items as $item) {
    $selection[] = $item['target_id'];
  }
  return $selection;
}