Example #1
0
 public function bsalted_payments()
 {
     $db = new db();
     $sessinon = new SessionHelper();
     $stage = new Event();
     $helper = new SiteHelper();
     $order_fields = $this->addition_fields_list();
     $user_fields = User::addition_fields_list();
     $user_id = User::getID();
     $chosen_course = User::getMeta($user_id, $user_fields['course']);
     $course_stages_data = array();
     $user_stages = User::getPaidStages();
     $is_user_has_deposit = User::getMeta($user_id, $user_fields['deposit']);
     $course_id = isset($_GET['course-id']) && !empty($_GET['course-id']) ? $_GET['course-id'] : User::getCourseID($user_id);
     if (isset($course_id) && !empty($course_id)) {
         $course_stages = $stage->getByParentID($course_id);
         foreach ($course_stages as $object) {
             $course_name = $stage->getNameByID($object->post_id);
             $course_stages_data[$course_name] = $object->post_id;
         }
         SessionHelper::set($order_fields['course'], $course_id);
         SessionHelper::set($order_fields['stages'], $course_stages_data);
     } else {
         SessionHelper::set($order_fields['stages'], 'DEPOSIT');
     }
     $helper->enqueue_script('bsalted-front', '/js/main/front.js');
     $helper->localize_js('bsalted-front', 'bsaltedAjax', array('ajaxurl' => admin_url('admin-ajax.php')));
     if (!empty($chosen_course) && count($user_stages) == 5) {
         $course_id = User::getCourseID($user_id);
         //prevent if get isset
         $course = $db->getEntry($course_id);
         echo '<div class="bsalted-payment-message"><h3>You have paid for all the stages of the course ' . $course->post_title . '</h3></div>';
     } elseif (isset($course_id) && !empty($course_id)) {
         include_once dirname(__FILE__) . '/view/bsalted-payments.php';
     } else {
         // echo '<div class="bsalted-payment-message"><h3> You need to choose Course Program first.</h3></div>';
         include_once dirname(__FILE__) . '/view/bsalted-payments.php';
     }
 }