Example #1
0
 static function instance($prop = false, $args = false)
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     $ins = self::$instance;
     if ($prop) {
         $prop = 'get_' . $prop;
     }
     return $prop && is_callable(array($ins, $prop)) ? call_user_func_array(array($ins, $prop), (array) $args) : $ins;
 }
/**
 * When user take a course clear the cart and add the new course into cart
 * Currently, user can be add only one course each time and do checkout right away
 *
 * @param $can_take
 * @param $user_id
 * @param $course_id
 * @param $payment_method
 * @return mixed
 */
function learn_press_before_take_course($can_take, $user_id, $course_id, $payment_method)
{
    // only one course in time
    LPR_Cart::instance()->empty_cart()->add_to_cart($course_id);
    return $can_take;
}