You are here

function uc_discounts_get_term_ids_for_discount_id in Ubercart Discounts (Alternative) 7.2

Return all term IDs used by a dicsount ID.

Parameters

int $discount_id:

const $grouping:

bool $exclude_all_terms:

Return value

array Array of term IDs.

3 calls to uc_discounts_get_term_ids_for_discount_id()
uc_discounts_admin_discount_copy_form in uc_discounts/uc_discounts.admin.inc
Generates admin form to create a copy of existing discount.
uc_discounts_get_product_ids_for_discount in uc_discounts/uc_discounts.module
Returns product IDs to which a discount applies.
_uc_discounts_product_filter_form in uc_discounts/uc_discounts.admin.inc
Helper function that creates a series of dropdowns for selecting a product via product_id, sku, class, term, or author.

File

uc_discounts/uc_discounts.module, line 1042

Code

function uc_discounts_get_term_ids_for_discount_id($discount_id, $grouping, $exclude_all_terms = FALSE) {
  $query = "SELECT term_id\n            FROM {uc_discounts_terms}\n            WHERE discount_id = :discount_id\n            AND grouping = :grouping";
  $args = array(
    ':discount_id' => $discount_id,
    ':grouping' => $grouping,
  );
  if ($exclude_all_terms) {
    $query .= ' AND term_id <> :term_id';
    $args[':term_id'] = UC_DISCOUNTS_OPTION_ALL_TERMS;
  }
  $result = db_query($query, $args);
  $ids = array();
  foreach ($result as $row) {
    $ids[] = $row->term_id;
  }
  return $ids;
}