function event_espresso_get_final_price($price_id = FALSE, $event_id = FALSE, $orig_price = FALSE) { do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, ''); if (!$price_id || !$event_id) { return FALSE; } if (event_espresso_verify_price_id($price_id, $event_id) == FALSE) { $orig_price = espresso_return_single_price($event_id); } $result = $orig_price !== FALSE ? $orig_price : event_espresso_get_orig_price_and_surcharge($price_id, $event_id); if (isset($result->event_cost)) { $result->event_cost = (double) $result->event_cost; } else { $result = new stdClass(); $result->event_cost = (double) $orig_price; } // if price is anything other than zero if ($result->event_cost > 0.0) { // Addition for Early Registration discount if ($early_price_data = early_discount_amount($event_id, $result->event_cost)) { $result->event_cost = $early_price_data['event_price']; } } if (event_espresso_verify_price_id($price_id, $event_id) == FALSE) { $result->event_cost = espresso_return_single_price($event_id); } $surcharge = event_espresso_calculate_surcharge($result->event_cost, $result->surcharge, $result->surcharge_type); $surcharge = !empty($surcharge) ? (double) $surcharge : 0; $event_cost = $result->event_cost + $surcharge; return (double) number_format($event_cost, 2, '.', ''); }
function event_espresso_add_attendees_to_db($event_id = NULL, $session_vars = NULL, $skip_check = FALSE) { do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, ''); //Security check using nonce if (empty($_POST['reg_form_nonce']) || !wp_verify_nonce($_POST['reg_form_nonce'], 'reg_nonce')) { print '<h3 class="error">' . __('Sorry, there was a security error and your registration was not saved.', 'event_espresso') . '</h3>'; return; } global $wpdb, $org_options, $espresso_premium; //Defaults $data_source = $_POST; $att_data_source = $_POST; $multi_reg = FALSE; $notifications = array('coupons' => '', 'groupons' => ''); if (!is_null($event_id) && !is_null($session_vars)) { //event details, ie qty, price, start.. $data_source = $session_vars['data']; //event attendee info ie name, questions.... $att_data_source = $session_vars['event_attendees']; $multi_reg = TRUE; } else { $event_id = absint($data_source['event_id']); } //Check for existing registrations //check if user has already hit this page before ( ie: going back n forth thru reg process ) $prev_session_id = isset($_SESSION['espresso_session']['id']) && !empty($_SESSION['espresso_session']['id']) ? $_SESSION['espresso_session']['id'] : ''; if (is_null($session_vars)) { $SQL = "SELECT id FROM " . EVENTS_ATTENDEE_TABLE . " WHERE attendee_session=%s"; $prev_session_attendee_id = $wpdb->get_col($wpdb->prepare($SQL, $_SESSION['espresso_session']['id'])); if (!empty($prev_session_attendee_id)) { $_SESSION['espresso_session']['id'] = array(); ee_init_session(); } } //Check to see if the registration id already exists $incomplete_filter = !$multi_reg ? " AND payment_status ='Incomplete'" : ''; $SQL = "SELECT attendee_session, id, registration_id FROM " . EVENTS_ATTENDEE_TABLE . " WHERE attendee_session =%s AND event_id = %d"; $SQL .= $incomplete_filter; $check_sql = $wpdb->get_results($wpdb->prepare($SQL, $prev_session_id, $event_id)); $nmbr_of_regs = $wpdb->num_rows; static $loop_number = 1; // delete previous entries from this session in case user is jumping back n forth between pages during the reg process if ($nmbr_of_regs > 0 && $loop_number == 1) { if (!isset($data_source['admin'])) { $SQL = "SELECT id, registration_id FROM " . EVENTS_ATTENDEE_TABLE . ' '; $SQL .= "WHERE attendee_session = %s "; $SQL .= $incomplete_filter; if ($mer_attendee_ids = $wpdb->get_results($wpdb->prepare($SQL, $prev_session_id))) { foreach ($mer_attendee_ids as $v) { //Added for seating chart addon if (defined('ESPRESSO_SEATING_CHART')) { $SQL = "DELETE FROM " . EVENTS_SEATING_CHART_EVENT_SEAT_TABLE . ' '; $SQL .= "WHERE attendee_id = %d"; $wpdb->query($wpdb->prepare($SQL, $v->id)); } //Delete the old attendee meta do_action('action_hook_espresso_save_attendee_meta', $v->id, 'original_attendee_details', '', TRUE); } } $SQL = "DELETE t1, t2 FROM " . EVENTS_ATTENDEE_TABLE . " t1 "; $SQL .= "JOIN " . EVENTS_ANSWER_TABLE . " t2 on t1.id = t2.attendee_id "; $SQL .= "WHERE t1.attendee_session = %s "; $SQL .= $incomplete_filter; $wpdb->query($wpdb->prepare($SQL, $prev_session_id)); //Added by Imon // First delete attempt might fail if there is no data in answer table. So, second attempt without joining answer table is taken bellow - $SQL = " DELETE FROM " . EVENTS_ATTENDEE_TABLE . ' '; $SQL .= "WHERE attendee_session = %s "; $SQL .= $incomplete_filter; $wpdb->query($wpdb->prepare($SQL, $prev_session_id)); // Clean up any attendee information from attendee_cost table where attendee is not available in attendee table event_espresso_cleanup_multi_event_registration_id_group_data(); } } $loop_number++; //Check if added admin $skip_check = $skip_check || isset($data_source['admin']) ? TRUE : FALSE; //If added by admin, skip the recaptcha check if (espresso_verify_recaptcha($skip_check)) { array_walk_recursive($data_source, 'wp_strip_all_tags'); array_walk_recursive($att_data_source, 'wp_strip_all_tags'); array_walk_recursive($data_source, 'espresso_apply_htmlentities'); array_walk_recursive($att_data_source, 'espresso_apply_htmlentities'); // Will be used for multi events to keep track of event id change in the loop, for recording event total cost for each group static $temp_event_id = ''; //using this var to keep track of the first attendee static $attendee_number = 1; static $total_cost = 0; static $primary_att_id = NULL; if ($temp_event_id == '' || $temp_event_id != $event_id) { $temp_event_id = $event_id; $event_change = 1; } else { $event_change = 0; } $event_cost = isset($data_source['cost']) && $data_source['cost'] != '' ? $data_source['cost'] : 0.0; $final_price = $event_cost; $fname = isset($att_data_source['fname']) ? ee_sanitize_value($att_data_source['fname']) : ''; $lname = isset($att_data_source['lname']) ? ee_sanitize_value($att_data_source['lname']) : ''; $address = isset($att_data_source['address']) ? ee_sanitize_value($att_data_source['address']) : ''; $address2 = isset($att_data_source['address2']) ? ee_sanitize_value($att_data_source['address2']) : ''; $city = isset($att_data_source['city']) ? ee_sanitize_value($att_data_source['city']) : ''; $state = isset($att_data_source['state']) ? ee_sanitize_value($att_data_source['state']) : ''; $country_id = isset($att_data_source['country']) ? ee_sanitize_value($att_data_source['country']) : ''; $zip = isset($att_data_source['zip']) ? ee_sanitize_value($att_data_source['zip']) : ''; $phone = isset($att_data_source['phone']) ? ee_sanitize_value($att_data_source['phone']) : ''; $email = isset($att_data_source['email']) ? ee_sanitize_value($att_data_source['email']) : ''; $SQL = "SELECT question_groups, event_meta FROM " . EVENTS_DETAIL_TABLE . " WHERE id = %d"; $questions = $wpdb->get_row($wpdb->prepare($SQL, $event_id)); //echo '<h4>LQ : ' . $wpdb->last_query . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; $event_meta = maybe_unserialize($questions->event_meta); $questions = maybe_unserialize($questions->question_groups); // Adding attenddee specific cost to events_attendee table if (isset($data_source['admin'])) { $attendee_quantity = 1; $final_price = (double) $data_source['event_cost']; $orig_price = (double) $data_source['event_cost']; $price_type = __('Admin', 'event_espresso'); } elseif (isset($data_source['seat_id'])) { // Added for seating chart add-on // If a seat was selected then price of that seating will be used instead of event price $final_price = (double) seating_chart::get_purchase_price($data_source['seat_id']); $orig_price = (double) $final_price; $price_type = $data_source['seat_id']; } elseif (isset($att_data_source['price_id']) && !empty($att_data_source['price_id'])) { $orig_price = event_espresso_get_orig_price_and_surcharge($att_data_source['price_id'], $event_id); $final_price = isset($att_data_source['price_id']) && !empty($data_source['price_id']) ? event_espresso_get_final_price(absint($att_data_source['price_id']), $event_id, $orig_price) : espresso_return_single_price($event_id); $price_type = isset($att_data_source['price_id']) && !empty($data_source['price_id']) ? espresso_ticket_information(array('type' => 'ticket', 'price_option' => absint($att_data_source['price_id']))) : ''; $surcharge = event_espresso_calculate_surcharge((double) $orig_price->event_cost, (double) $orig_price->surcharge, $orig_price->surcharge_type); $orig_price = (double) number_format($orig_price->event_cost + $surcharge, 2, '.', ''); } elseif (isset($data_source['price_select']) && $data_source['price_select'] == TRUE) { //Figure out if the person has registered using a price selection $price_options = explode('|', ee_sanitize_value($data_source['price_option']), 2); $price_id = absint($price_options[0]); $price_type = $price_options[1]; $orig_price = event_espresso_get_orig_price_and_surcharge($price_id, $event_id); $final_price = event_espresso_get_final_price($price_id, $event_id, $orig_price); $surcharge = event_espresso_calculate_surcharge($orig_price->event_cost, $orig_price->surcharge, $orig_price->surcharge_type); $orig_price = (double) number_format($orig_price->event_cost + $surcharge, 2, '.', ''); } else { $orig_price = isset($data_source['price_id']) && !empty($data_source['price_id']) ? event_espresso_get_orig_price_and_surcharge(absint($data_source['price_id']), $event_id) : espresso_return_single_price($event_id); $final_price = isset($data_source['price_id']) && !empty($data_source['price_id']) ? event_espresso_get_final_price(absint($data_source['price_id']), $event_id, $orig_price) : espresso_return_single_price($event_id); $price_type = isset($data_source['price_id']) && !empty($data_source['price_id']) ? espresso_ticket_information(array('type' => 'ticket', 'price_option' => absint($data_source['price_id']))) : ''; $surcharge = isset($orig_price->surcharge) && isset($orig_price->event_cost) ? event_espresso_calculate_surcharge($orig_price->event_cost, $orig_price->surcharge, $orig_price->surcharge_type) : 0.0; $orig_price = isset($orig_price->event_cost) ? (double) number_format($orig_price->event_cost + $surcharge, 2, '.', '') : espresso_return_single_price($event_id); } $final_price = apply_filters('filter_hook_espresso_attendee_cost', $final_price); $attendee_quantity = isset($data_source['num_people']) ? $data_source['num_people'] : 1; $coupon_code = ''; if ($multi_reg) { $event_cost = $_SESSION['espresso_session']['grand_total']; } do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, 'line ' . __LINE__ . ' : attendee_cost=' . $final_price); $event_cost = apply_filters('filter_hook_espresso_cart_grand_total', $event_cost); $amount_pd = 0.0; //Check if the registration id has been created previously. $registration_id = empty($wpdb->last_result[0]->registration_id) ? apply_filters('filter_hook_espresso_registration_id', $event_id) : $wpdb->last_result[0]->registration_id; $txn_type = ""; if (isset($data_source['admin'])) { $payment_status = "Completed"; $payment = "Admin"; $txn_type = __('Added by Admin', 'event_espresso'); $payment_date = date(get_option('date_format')); $amount_pd = !empty($data_source['event_cost']) ? $data_source['event_cost'] : 0.0; $registration_id = uniqid('', true); $_SESSION['espresso_session']['id'] = uniqid('', true); } else { //print_r( $event_meta); $default_payment_status = $event_meta['default_payment_status'] != '' ? $event_meta['default_payment_status'] : $org_options['default_payment_status']; $payment_status = $multi_reg && $data_source['cost'] == 0.0 ? "Completed" : $default_payment_status; $payment = ''; } $times_sql = "SELECT ese.start_time, ese.end_time, e.start_date, e.end_date "; $times_sql .= "FROM " . EVENTS_START_END_TABLE . " ese "; $times_sql .= "LEFT JOIN " . EVENTS_DETAIL_TABLE . " e ON ese.event_id = e.id WHERE "; $times_sql .= "e.id=%d"; if (!empty($data_source['start_time_id'])) { $times_sql .= " AND ese.id=" . absint($data_source['start_time_id']); } $times = $wpdb->get_results($wpdb->prepare($times_sql, $event_id)); foreach ($times as $time) { $start_time = $time->start_time; $end_time = $time->end_time; $start_date = $time->start_date; $end_date = $time->end_date; } //If we are using the number of attendees dropdown, add that number to the DB //echo $data_source['espresso_addtl_limit_dd']; if (isset($data_source['espresso_addtl_limit_dd'])) { $num_people = absint($data_source['num_people']); } elseif (isset($event_meta['additional_attendee_reg_info']) && $event_meta['additional_attendee_reg_info'] == 1) { $num_people = absint($data_source['num_people']); } else { $num_people = 1; } // check for coupon if (function_exists('event_espresso_process_coupon')) { if ($coupon_results = event_espresso_process_coupon($event_id, $final_price, $multi_reg)) { //printr( $coupon_results, '$coupon_results <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); if ($coupon_results['valid']) { $final_price = number_format($coupon_results['event_cost'], 2, '.', ''); $coupon_code = $coupon_results['code']; } if (!$multi_reg && !empty($coupon_results['msg'])) { $notifications['coupons'] = $coupon_results['msg']; } } } // check for groupon if (function_exists('event_espresso_process_groupon')) { if ($groupon_results = event_espresso_process_groupon($event_id, $final_price, $multi_reg)) { //printr( $groupon_results, '$groupon_results <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); if ($groupon_results['valid']) { $final_price = number_format($groupon_results['event_cost'], 2, '.', ''); $coupon_code = $groupon_results['code']; } if (!$multi_reg && !empty($groupon_results['msg'])) { $notifications['groupons'] = $groupon_results['msg']; } } } $start_time = empty($start_time) ? '' : $start_time; $end_time = empty($end_time) ? '' : $end_time; $start_date = empty($start_date) ? '' : $start_date; $end_date = empty($end_date) ? '' : $end_date; $organization_name = empty($organization_name) ? '' : $organization_name; $country_id = empty($country_id) ? '' : $country_id; $payment_date = empty($payment_date) ? '' : $payment_date; $coupon_code = empty($coupon_code) ? '' : $coupon_code; $amount_pd = number_format((double) $amount_pd, 2, '.', ''); $orig_price = number_format((double) $orig_price, 2, '.', ''); $final_price = number_format((double) $final_price, 2, '.', ''); $total_cost = $total_cost + $final_price; $columns_and_values = array('registration_id' => $registration_id, 'is_primary' => $attendee_number == 1 ? TRUE : FALSE, 'attendee_session' => $_SESSION['espresso_session']['id'], 'lname' => $lname, 'fname' => $fname, 'address' => $address, 'address2' => $address2, 'city' => $city, 'state' => $state, 'country_id' => $country_id, 'zip' => $zip, 'email' => $email, 'phone' => $phone, 'payment' => $payment, 'txn_type' => $txn_type, 'coupon_code' => $coupon_code, 'event_time' => $start_time, 'end_time' => $end_time, 'start_date' => $start_date, 'end_date' => $end_date, 'price_option' => $price_type, 'organization_name' => $organization_name, 'payment_status' => $payment_status, 'payment_date' => $payment_date, 'event_id' => $event_id, 'quantity' => (int) $num_people, 'amount_pd' => $amount_pd, 'orig_price' => $orig_price, 'final_price' => $final_price); $data_formats = array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%f', '%f', '%f'); // save the attendee details - FINALLY !!! if (!$wpdb->insert(EVENTS_ATTENDEE_TABLE, $columns_and_values, $data_formats)) { $error = true; } //echo '<h4>LQ : ' . $wpdb->last_query . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; $attendee_id = $wpdb->insert_id; $attendee_data = $columns_and_values; $attendee_data['attendee_id'] = $attendee_id; $attendee_data['event_meta'] = $event_meta; //Save attendee hook do_action('action_hook_espresso_save_attendee_data', $attendee_data); //Save the attendee data as a meta value do_action('action_hook_espresso_save_attendee_meta', $attendee_id, 'original_attendee_details', serialize($attendee_data)); // save attendee id for the primary attendee $primary_att_id = $attendee_number == 1 ? $attendee_id : FALSE; // Added for seating chart addon $booking_id = 0; if (defined('ESPRESSO_SEATING_CHART')) { if (seating_chart::check_event_has_seating_chart($event_id) !== false) { if (isset($_POST['seat_id'])) { $booking_id = seating_chart::parse_booking_info(ee_sanitize_value($_POST['seat_id'])); if ($booking_id > 0) { seating_chart::confirm_a_seat($booking_id, $attendee_id); } } } } //Add a record for the primary attendee if ($attendee_number == 1) { $columns_and_values = array('attendee_id' => $primary_att_id, 'meta_key' => 'primary_attendee', 'meta_value' => 1); $data_formats = array('%s', '%s', '%s'); if (!$wpdb->insert(EVENTS_ATTENDEE_META_TABLE, $columns_and_values, $data_formats)) { $error = true; } } if (defined('EVENTS_MAILCHIMP_ATTENDEE_REL_TABLE') && $espresso_premium == true) { MailChimpController::list_subscribe($event_id, $attendee_id, $fname, $lname, $email); } //Defining the $base_questions variable in case there are no additional attendee questions $base_questions = $questions; //Since main attendee and additional attendees may have different questions, //$attendee_number check for 2 because is it statically set at 1 first and is incremented for the primary attendee above, hence 2 $questions = $attendee_number > 1 && isset($event_meta['add_attendee_question_groups']) ? $event_meta['add_attendee_question_groups'] : $questions; add_attendee_questions($questions, $registration_id, $attendee_id, array('session_vars' => $att_data_source)); //Add additional attendees to the database if ($event_meta['additional_attendee_reg_info'] > 1) { $questions = $event_meta['add_attendee_question_groups']; if (empty($questions)) { $questions = $base_questions; } if (isset($att_data_source['x_attendee_fname'])) { foreach ($att_data_source['x_attendee_fname'] as $k => $v) { if (trim($v) != '' && trim($att_data_source['x_attendee_lname'][$k]) != '') { // Added for seating chart addon $seat_check = true; $x_booking_id = 0; if (defined('ESPRESSO_SEATING_CHART')) { if (seating_chart::check_event_has_seating_chart($event_id) !== false) { if (!isset($att_data_source['x_seat_id'][$k]) || trim($att_data_source['x_seat_id'][$k]) == '') { $seat_check = false; } else { $x_booking_id = seating_chart::parse_booking_info($att_data_source['x_seat_id'][$k]); if ($x_booking_id > 0) { $seat_check = true; $price_type = $att_data_source['x_seat_id'][$k]; $final_price = seating_chart::get_purchase_price($att_data_source['x_seat_id'][$k]); $orig_price = $final_price; } else { $seat_check = false; //Keeps the system from adding an additional attndee if no seat is selected } } } } if ($seat_check) { $ext_att_data_source = array('registration_id' => $registration_id, 'attendee_session' => $_SESSION['espresso_session']['id'], 'lname' => ee_sanitize_value($att_data_source['x_attendee_lname'][$k]), 'fname' => ee_sanitize_value($v), 'email' => ee_sanitize_value($att_data_source['x_attendee_email'][$k]), 'address' => empty($att_data_source['x_attendee_address'][$k]) ? '' : ee_sanitize_value($att_data_source['x_attendee_address'][$k]), 'address2' => empty($att_data_source['x_attendee_address2'][$k]) ? '' : ee_sanitize_value($att_data_source['x_attendee_address2'][$k]), 'city' => empty($att_data_source['x_attendee_city'][$k]) ? '' : ee_sanitize_value($att_data_source['x_attendee_city'][$k]), 'state' => empty($att_data_source['x_attendee_state'][$k]) ? '' : ee_sanitize_value($att_data_source['x_attendee_state'][$k]), 'zip' => empty($att_data_source['x_attendee_zip'][$k]) ? '' : ee_sanitize_value($att_data_source['x_attendee_zip'][$k]), 'phone' => empty($att_data_source['x_attendee_phone'][$k]) ? '' : ee_sanitize_value($att_data_source['x_attendee_phone'][$k]), 'payment' => $payment, 'event_time' => $start_time, 'end_time' => $end_time, 'start_date' => $start_date, 'end_date' => $end_date, 'price_option' => $price_type, 'organization_name' => $organization_name, 'country_id' => $country_id, 'payment_status' => $payment_status, 'payment_date' => $payment_date, 'event_id' => $event_id, 'quantity' => (int) $num_people, 'amount_pd' => 0.0, 'orig_price' => $orig_price, 'final_price' => $final_price); $format = array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%f', '%f', '%f'); $wpdb->insert(EVENTS_ATTENDEE_TABLE, $ext_att_data_source, $format); //Added by Imon $ext_attendee_id = $wpdb->insert_id; $ext_att_data_source['attendee_id'] = $attendee_id; $ext_att_data_source['event_meta'] = $event_meta; //Save attendee hook do_action('action_hook_espresso_save_attendee_data', $ext_att_data_source); //Save the attendee data as a meta value do_action('action_hook_espresso_save_attendee_meta', $ext_attendee_id, 'original_attendee_details', serialize($ext_att_data_source)); $mailchimp_attendee_id = $ext_attendee_id; if (defined('EVENTS_MAILCHIMP_ATTENDEE_REL_TABLE') && $espresso_premium == true) { MailChimpController::list_subscribe($event_id, $mailchimp_attendee_id, $v, $att_data_source['x_attendee_lname'][$k], $att_data_source['x_attendee_email'][$k]); } if (!is_array($questions) && !empty($questions)) { $questions = unserialize($questions); } $questions_in = ''; foreach ($questions as $g_id) { $questions_in .= $g_id . ','; } $questions_in = substr($questions_in, 0, -1); $SQL = "SELECT q.*, qg.group_name FROM " . EVENTS_QUESTION_TABLE . " q "; $SQL .= "JOIN " . EVENTS_QST_GROUP_REL_TABLE . " qgr on q.id = qgr.question_id "; $SQL .= "JOIN " . EVENTS_QST_GROUP_TABLE . " qg on qg.id = qgr.group_id "; $SQL .= "WHERE qgr.group_id in ( {$questions_in} ) "; $SQL .= "ORDER BY q.id ASC"; $questions_list = $wpdb->get_results($wpdb->prepare($SQL, NULL)); foreach ($questions_list as $question_list) { if ($question_list->system_name != '') { $ext_att_data_source[$question_list->system_name] = $att_data_source['x_attendee_' . $question_list->system_name][$k]; } else { $ext_att_data_source[$question_list->question_type . '_' . $question_list->id] = isset($att_data_source['x_attendee_' . $question_list->question_type . '_' . $question_list->id][$k]) && !empty($att_data_source['x_attendee_' . $question_list->question_type . '_' . $question_list->id][$k]) ? $att_data_source['x_attendee_' . $question_list->question_type . '_' . $question_list->id][$k] : ''; } } echo add_attendee_questions($questions, $registration_id, $ext_attendee_id, array('session_vars' => $ext_att_data_source)); } // Added for seating chart addon if (defined('ESPRESSO_SEATING_CHART')) { if (seating_chart::check_event_has_seating_chart($event_id) !== false && $x_booking_id > 0) { seating_chart::confirm_a_seat($x_booking_id, $ext_attendee_id); } } } } } } //Add member data if needed if (defined('EVENTS_MEMBER_REL_TABLE')) { require_once EVENT_ESPRESSO_MEMBERS_DIR . "member_functions.php"; //Load Members functions require EVENT_ESPRESSO_MEMBERS_DIR . "user_vars.php"; //Load Members functions if ($userid != 0) { event_espresso_add_user_to_event($event_id, $userid, $attendee_id); } } $attendee_number++; if (isset($data_source['admin'])) { return $attendee_id; } //This shows the payment page if (!$multi_reg) { return events_payment_page($attendee_id, $notifications); } return array('registration_id' => $registration_id, 'notifications' => $notifications); } }
function get_espresso_price_sc($atts) { extract(shortcode_atts(array('event_id' => '0', 'number' => '0'), $atts)); $event_id = "{$event_id}"; $number = "{$number}"; ob_start(); echo espresso_return_single_price($event_id, $number); $buffer = ob_get_contents(); ob_end_clean(); return $buffer; }
function event_espresso_get_final_price($price_id = FALSE, $event_id = FALSE) { do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, ''); if (!$price_id || !$event_id) { return 1000000; } global $wpdb; $sql = "SELECT id, event_cost, surcharge, surcharge_type FROM " . EVENTS_PRICES_TABLE . " WHERE id='" . $price_id . "' ORDER BY id ASC LIMIT 1"; if (is_user_logged_in()) { $sql = "SELECT id, member_price event_cost, surcharge, surcharge_type FROM " . EVENTS_PRICES_TABLE . " WHERE id='" . $price_id . "' ORDER BY id ASC LIMIT 1"; } do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, 'sql=' . $sql); $results = $wpdb->get_results($sql); foreach ($results as $result) { if ($wpdb->num_rows >= 1) { if ($result->event_cost > 0.0) { $event_cost = $result->event_cost; // Addition for Early Registration discount if ($early_price_data = early_discount_amount($event_id, $event_cost)) { $event_cost = $early_price_data['event_price']; } $surcharge = $result->surcharge; //by default it's 0. if flat rate, will just be formatted and atted to the total if ($result->surcharge > 0 && $result->surcharge_type == 'pct') { //if >0 and is percent, calculate surcharg amount to be added to total $surcharge = $event_cost * $result->surcharge / 100; } $event_cost += $surcharge; } else { $event_cost = __('0.00', 'event_espresso'); } } else { if ($wpdb->num_rows == 0) { $event_cost = __('0.00', 'event_espresso'); } } } if (event_espresso_verify_price_id($price_id, $event_id) == FALSE) { $event_cost = espresso_return_single_price($event_id); } return empty($event_cost) ? 0 : $event_cost; }
function get_espresso_price_sc($atts) { extract(shortcode_atts(array('event_id' => '0', 'number' => '0'), $atts)); $event_id = "{$event_id}"; $number = "{$number}"; return espresso_return_single_price($event_id, $number); }