Ejemplo n.º 1
0
 public function add_order_meta($order_id)
 {
     $user_id = User::getID();
     $user_consultant_code = User::getConsultantCode();
     $user_fields = User::addition_fields_list();
     $user_types_fields = User::types_fields_list();
     $stage_fields = Event::addition_fields_list();
     $order_fields = $this->addition_fields_list();
     $chosen_stages = SessionHelper::get($order_fields['offer']);
     $course_stages = SessionHelper::get($order_fields['stages']);
     $ordered_stages_name = SessionHelper::get($order_fields['user-stages']);
     $confirmed_field = '_' . $stage_fields['confirmed'];
     $products = SiteHelper::product_stage_relation();
     $user_stages = User::getPaidStages();
     $user_order_stage_data = array();
     if ($chosen_stages === 'deposit_offer') {
         User::updateMeta($user_id, $user_fields['deposit'], $products['DEPOSIT']);
         SiteHelper::send_info_to_director($user_id);
     } elseif ($chosen_stages === 'first_offer') {
         #&& array_key_exists('INT', $course_stages)
         $stage_name = $ordered_stages_name;
         $stage_id = $course_stages[$stage_name];
         $stage_confirmed = db::getEntryMeta($stage_id, $confirmed_field) === '' ? 0 : db::getEntryMeta($stage_id, $confirmed_field)[0];
         $protege_assessment_id = SiteHelper::generate_assessment_entry($stage_name, $user_id, $stage_id);
         $savant_assessment_id = SiteHelper::generate_assessment_entry($stage_name, $user_id, $stage_id, 'savant');
         // $success = !is_wp_error($protege_assessment_id);
         User::updateMeta($user_id, $user_fields['order'] . $stage_name, $order_id);
         User::updateMeta($user_id, $stage_fields['name'] . $stage_name, $stage_id);
         User::updateMeta($user_id, $user_fields['assessment-protege'] . $stage_name, $protege_assessment_id);
         User::updateMeta($user_id, $user_fields['assessment-savant'] . $stage_name, $savant_assessment_id);
         db::updateEntryMeta($stage_id, $confirmed_field, ++$stage_confirmed);
     } elseif ($chosen_stages === 'second_offer') {
         foreach ($ordered_stages_name as $stage_name) {
             $stage_id = $course_stages[$stage_name];
             $stage_confirmed = db::getEntryMeta($stage_id, $confirmed_field) === '' ? 0 : db::getEntryMeta($stage_id, $confirmed_field)[0];
             if ($stage_name === 'PRE') {
                 $savant_assessment_id = SiteHelper::generate_assessment_entry($stage_name, $user_id, $stage_id, 'savant');
             } else {
                 $protege_assessment_id = SiteHelper::generate_assessment_entry($stage_name, $user_id, $stage_id);
                 $savant_assessment_id = SiteHelper::generate_assessment_entry($stage_name, $user_id, $stage_id, 'savant');
             }
             User::updateMeta($user_id, $user_fields['order'] . $stage_name, $order_id);
             User::updateMeta($user_id, $stage_fields['name'] . $stage_name, $stage_id);
             User::updateMeta($user_id, $user_fields['assessment-protege'] . $stage_name, $protege_assessment_id);
             User::updateMeta($user_id, $user_fields['assessment-savant'] . $stage_name, $savant_assessment_id);
             db::updateEntryMeta($stage_id, $confirmed_field, ++$stage_confirmed);
         }
     }
     db::updateEntryMeta($order_id, $order_fields['course'], SessionHelper::get($order_fields['course']));
     db::updateEntryMeta($order_id, $order_fields['consultant'], $user_consultant_code);
     User::updateMeta($user_id, $user_fields['course'], SessionHelper::get($order_fields['course']));
     SessionHelper::destroy();
 }
<?php

use Nerds\Bsalted\Entity\UserEntity\User;
use Nerds\Bsalted\Entity\EventEntity\Event;
use Nerds\Base\Util\Helpers\SessionHelper;
use Nerds\Base\Util\Helpers\SiteHelper;
$order_fields = $this->addition_fields_list();
$user_stages = User::getPaidStages();
$products = array_keys(SiteHelper::product_stage_relation());
$is_user_has_deposit = User::getMeta($user_id, $user_fields['deposit']);
$is_user_has_proposals = User::getMeta($user_id, $user_fields['proposals']);
$course_id = isset($_GET['course-id']) && !empty($_GET['course-id']) ? $_GET['course-id'] : User::getCourseID($user_id);
$course = $db->getEntry($course_id);
$stage1 = new Event();
#var_dump($stage1->getConfirmedByCountry(876));
#var_dump(User::getBoughtStage('stage-name-PRE', 876));
#var_dump(User::getRegistrationForm(106)[11]);
?>

<?php 
if (!User::is_filled_registration()) {
    ?>
	<h2>Please fill the <a href="<?php 
    echo site_url();
    ?>
/account/adventures-registration-form/">Registration Form</a></h2>
<?php 
} elseif (empty($is_user_has_deposit)) {
    ?>
	<div class="bsalted-payments">
		<h3 class="noPay">To begin just put money on your deposit:</h3>