You are here

function course_uc_check_purchased in Course 7.2

Same name and namespace in other branches
  1. 8.3 modules/course_uc/course_uc.module \course_uc_check_purchased()
  2. 8.2 modules/course_uc/course_uc.module \course_uc_check_purchased()
  3. 7 modules/course_uc/course_uc.module \course_uc_check_purchased()
  4. 3.x modules/course_uc/course_uc.module \course_uc_check_purchased()

Check if a user purchased a course previously.

Alias of course_enrollment_load().

3 calls to course_uc_check_purchased()
course_uc_course_access in modules/course_uc/course_uc.module
Implements hook_course_access().
course_uc_form_alter in modules/course_uc/course_uc.module
Implements hook_form_alter().
course_uc_uc_add_to_cart in modules/course_uc/course_uc.module
Implements hook_add_to_cart().

File

modules/course_uc/course_uc.module, line 266

Code

function course_uc_check_purchased($uid, $nid, $data = array()) {
  $uid = isset($data['uid']) ? $data['uid'] : $uid;
  $orders = entity_load('uc_order', FALSE, array(
    'uid' => $uid,
  ));
  foreach ($orders as $order) {
    if ($order->order_status == 'complete') {
      foreach ($order->products as $product) {
        if ($product->nid == $nid) {
          return TRUE;
        }
      }
    }
  }
  return FALSE;
}