function course_commerce_uc_add_to_cart in Course 3.x
Implements hook_add_to_cart().
File
- modules/
course_commerce/ course_commerce.module, line 244
Code
function course_commerce_uc_add_to_cart($nid, $qty, $data) {
if (Drupal::config('course_uc.settings')
->get('restrict_qty', 1)) {
$user = Drupal::currentUser();
$node = Node::load($nid);
if (course_node_is_course($node)) {
if (course_uc_check_purchased($user, $node, $data)) {
return array(
array(
'success' => FALSE,
'message' => t('You have already purchased this course.'),
'silent' => FALSE,
),
);
}
if (course_uc_check_cart($node, $user, $data)) {
$link = Link::createFromRoute(t('shopping cart'), 'uc_cart.cart');
return array(
array(
'success' => FALSE,
'message' => t('This course is already in your @cart.', array(
'@cart' => $link
->toString(),
)),
'silent' => FALSE,
),
);
}
}
}
}