You are here

function commerce_gc_load_user_giftcards in Commerce GC 7

Load giftcard that belong to a certain user.

Parameters

type $uid:

type $active:

Return value

type

File

./commerce_gc.module, line 981
Provides Giftcard coupon bundle, Giftcard Transaction entity and basic user interface elements.

Code

function commerce_gc_load_user_giftcards($uid, $active = TRUE) {
  $coupons = array();
  $query = new EntityFieldQuery();
  $results = $query
    ->entityCondition('entity_type', 'commerce_coupon')
    ->entityCondition('bundle', 'giftcard_coupon')
    ->fieldCondition('commerce_coupon_recipient', 'target_id', $uid)
    ->propertyCondition('status', $active)
    ->execute();
  if (!empty($results['commerce_coupon'])) {
    $coupons = commerce_coupon_load_multiple(array_keys($results['commerce_coupon']));
  }
  return $coupons;
}