function course_uc_check_cart in Course 7.2
Same name and namespace in other branches
- 8.3 modules/course_uc/course_uc.module \course_uc_check_cart()
- 8.2 modules/course_uc/course_uc.module \course_uc_check_cart()
- 7 modules/course_uc/course_uc.module \course_uc_check_cart()
- 3.x modules/course_uc/course_uc.module \course_uc_check_cart()
Check if a course is already in a user's cart.
Note that we have to check if the user is purchasing the course for someone else.
1 call to course_uc_check_cart()
- 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 287
Code
function course_uc_check_cart($nid, $uid, $data = array()) {
$cid = uc_cart_get_id();
$contents = uc_cart_get_contents($cid);
$uid = isset($data['uid']) ? $data['uid'] : $uid;
foreach ($contents as $item) {
// Check if user already has course in their cart, if the user already is
// purchasing this course for somebody else.
if ($item->nid == $nid && (!isset($item->data['uid']) || $item->data['uid'] == $uid)) {
return TRUE;
}
}
}