function course_uc_form_alter in Course 6
Same name and namespace in other branches
- 8.3 modules/course_uc/course_uc.module \course_uc_form_alter()
- 8.2 modules/course_uc/course_uc.module \course_uc_form_alter()
- 7.2 modules/course_uc/course_uc.module \course_uc_form_alter()
- 7 modules/course_uc/course_uc.module \course_uc_form_alter()
- 3.x modules/course_uc/course_uc.module \course_uc_form_alter()
Implements hook_form_alter().
Hide the add to cart button when the user satisfied the requirement.
File
- modules/
course_uc/ course_uc.module, line 8
Code
function course_uc_form_alter(&$form, &$form_state, $form_id) {
if (strpos($form_id, 'uc_product_add_to_cart') !== FALSE) {
global $user;
$node = node_load($form['nid']['#value']);
if (course_node_is_course($node)) {
$course = course_get_course($node, $user);
}
else {
$courseNode = course_get_context('course_uc', 'payment', $node->nid);
$course = course_get_course($courseNode, $user);
}
foreach ($course
->getObjects() as $idx => $courseObject) {
if ($courseObject
->getComponent() == 'payment' && $courseObject
->getInstanceId() == $node->nid) {
if ($courseObject
->getFulfillment()
->isComplete()) {
$form['#access'] = FALSE;
}
}
}
}
}