示例#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();
 }