You are here

function commerce_coupon_code_is_active in Commerce Coupon 7

Checks if a given coupon code is active or not.

Parameters

$code: Coupon code to check.

Return value

void Returns TRUE if it is active else FALSE

File

./commerce_coupon.module, line 836
Coupon System for Drupal Commerce.

Code

function commerce_coupon_code_is_active($code) {

  // @TODO: Replace this query with drupal 7 query API
  $rs = db_query('SELECT * FROM {commerce_coupon} WHERE code = :code AND is_active = 1', array(
    ':code' => $code,
  ));
  $codeObject = $rs
    ->fetchObject();
  if ($codeObject == NULL) {
    return FALSE;
  }
  return TRUE;
}