You are here

function CourseObjectUbercart::take in Course 7

Same name and namespace in other branches
  1. 8.3 modules/course_uc/course_uc.classes.inc \CourseObjectUbercart::take()
  2. 8.2 modules/course_uc/course_uc.classes.inc \CourseObjectUbercart::take()
  3. 6 modules/course_uc/course_uc.classes.inc \CourseObjectUbercart::take()
  4. 7.2 modules/course_uc/course_uc.classes.inc \CourseObjectUbercart::take()

Display the add to cart button, or a message that it was already purchased.

Implementing classes should override me if a custom display is desired.

Overrides CourseObject::take

File

modules/course_uc/course_uc.classes.inc, line 21

Class

CourseObjectUbercart

Code

function take() {
  if (!($this->node->sell_price > 0) && variable_get('course_access_bypass_checkout', 1)) {
    $this
      ->getFulfillment()
      ->setComplete(1)
      ->save();
  }
  if ($this
    ->getFulfillment()
    ->isComplete()) {
    return "You've already purchased this activity.";
  }
  else {
    $node_view = node_view($this->node);
    $atc = t('You must purchase this course before proceeding.') . drupal_render($node_view['display_price']) . drupal_render($node_view['add_to_cart']);
    if (!$atc) {

      // The add to cart form was hidden?
      return "Something isn't right...";
    }
    else {
      return $atc;
    }
  }
}