function course_uc_restrict_qty_uc_cart_alter in Course 6
Implements hook_uc_cart_alter().
File
- modules/
course_uc/ course_uc.module, line 189
Code
function course_uc_restrict_qty_uc_cart_alter(&$cart_items) {
if (variable_get('course_uc_restrict_qty', 1)) {
global $user;
foreach ($cart_items as $key => $cart_item) {
$node = node_load($cart_item->nid);
if (course_node_is_course($node) && $cart_item->qty > 1) {
$cart_items[$key]->qty = 1;
$sql = "update {uc_cart_products} set qty = 1 where cart_id = %d AND nid = %d";
db_query($sql, $user->uid, $node->nid);
if (!$message) {
drupal_set_message('Sorry, you may not purchase multiple identical courses.', 'error');
$message = true;
}
}
}
}
}