You are here

function course_uc_restrict_qty_add_to_cart in Course 6

Implements hook_add_to_cart().

File

modules/course_uc/course_uc.module, line 135

Code

function course_uc_restrict_qty_add_to_cart($nid, $qty, $data) {
  if (variable_get('course_uc_restrict_qty', 1)) {
    global $user;
    $node = node_load($nid);
    if (course_node_is_course($node)) {
      if (course_uc_restrict_qty_check_purchased($user->uid, $nid)) {
        return array(
          array(
            'success' => FALSE,
            'message' => "You've already purchased this course.",
            'silent' => FALSE,
          ),
        );
      }
      if (course_uc_restrict_qty_check_cart($user->uid, $nid)) {
        return array(
          array(
            'success' => FALSE,
            'message' => t("This course is already in your !cart.", array(
              '!cart' => l('shopping cart', 'cart'),
            )),
            'silent' => FALSE,
          ),
        );
      }
    }
  }
}