function espresso_attendee_admin_price_dropdown($event_id, $atts) { extract($atts); global $wpdb, $org_options, $espresso_premium; if ($espresso_premium != true) { return; } $html = ''; $label = isset($label) && $label != '' ? $label : '<span class="section-title">' . __('Choose an Option: ', 'event_espresso') . '</span>'; $results = $wpdb->get_results("SELECT id, event_cost, surcharge, surcharge_type, price_type FROM " . EVENTS_PRICES_TABLE . " WHERE event_id='" . $event_id . "' ORDER BY id ASC"); //echo "<pre>".print_r($results,true)."</pre>"; //If more than one price was added to an event, we need to create a drop down to select the price. if ($wpdb->num_rows > 1) { //Create the label for the drop down $html .= $show_label == 1 ? '<label for="event_cost">' . $label . '</label>' : ''; //Create a dropdown of prices $html .= '<select name="price_option" id="price_option-' . $event_id . '">'; foreach ($results as $result) { $selected = isset($current_value) && $current_value == $result->price_type ? ' selected="selected" ' : ''; // 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']; $message = __(' Early Pricing', 'event_espresso'); } else { $message = ''; } $surcharge = ''; if ($result->surcharge > 0 && $result->event_cost > 0.0) { $surcharge = " + {$org_options['currency_symbol']}{$result->surcharge} "; if ($result->surcharge_type == 'pct') { $surcharge = " + {$result->surcharge}% "; } } //Using price ID $html .= '<option' . $selected . ' value="' . $result->id . '|' . $result->price_type . '">' . $result->price_type . ' (' . $org_options['currency_symbol'] . number_format($result->event_cost, 2) . $message . ') ' . $surcharge . ' </option>'; } $html .= '</select><input type="hidden" name="price_select" id="price_select-' . $event_id . '" value="true" />'; } //echo 'ts'; echo $html; }
function event_espresso_get_final_price($price_id, $event_id = 0) { global $espresso_premium; if ($espresso_premium != true) { return; } global $wpdb, $org_options; //Added the following 5 lines, as this was causing non-members to get the member price. if (is_user_logged_in()) { $prices = $wpdb->get_results("SELECT id, event_cost, member_price, surcharge FROM " . EVENTS_PRICES_TABLE . " WHERE id='" . $price_id . "' ORDER BY id ASC LIMIT 1"); } else { $prices = $wpdb->get_results("SELECT id, event_cost, surcharge FROM " . EVENTS_PRICES_TABLE . " WHERE id='" . $price_id . "' ORDER BY id ASC LIMIT 1"); } //$prices = $wpdb->get_results("SELECT id, event_cost, member_price, surcharge FROM " . EVENTS_PRICES_TABLE . " WHERE id='".$price_id."' ORDER BY id ASC LIMIT 1"); foreach ($prices as $price) { if ($wpdb->num_rows >= 1) { $member_price = $price->member_price == "" ? $price->event_cost : $price->member_price; if ($member_price > 0.0) { $member_price = $price->surcharge > 0.0 && $member_price > 0.0 ? $member_price + number_format($member_price * $price->surcharge / 100, 2, '.', '') : $member_price; // Addition for Early Registration discount if (early_discount_amount($event_id, $member_price) != false) { $early_price_data = array(); $early_price_data = early_discount_amount($event_id, $member_price); $member_price = $early_price_data['event_price']; } } else { $member_price = 0.0; } } else { if ($wpdb->num_rows == 0) { $member_price = 0.0; } } } return $member_price; }
function event_espresso_price_dropdown($event_id, $label = 1, $multi_reg = 0, $value = '') { //Attention: //If changes to this function are not appearing, you may have the members addon installed and will need to update the function there. global $wpdb, $org_options; $html = ''; //Will make the name an array and put the time id as a key so we know which event this belongs to $multi_name_adjust = $multi_reg == 1 ? "[{$event_id}]" : ''; $surcharge_text = isset($org_options['surcharge_text']) ? $org_options['surcharge_text'] : __('Surcharge', 'event_espresso'); $results = $wpdb->get_results("SELECT id, event_cost, surcharge, surcharge_type, price_type FROM " . EVENTS_PRICES_TABLE . " WHERE event_id='" . $event_id . "' ORDER BY id ASC"); if ($wpdb->num_rows > 1) { $html .= $label == 1 ? '<label for="event_cost">' . __('Choose an Option: ', 'event_espresso') . '</label>' : ''; $html .= '<select name="price_option' . $multi_name_adjust . '" id="price_option-' . $event_id . '">'; foreach ($results as $result) { $selected = $value == $result->id ? ' selected="selected" ' : ''; // Addition for Early Registration discount if (early_discount_amount($event_id, $result->event_cost) != false) { $early_price_data = array(); $early_price_data = early_discount_amount($event_id, $result->event_cost); $result->event_cost = $early_price_data['event_price']; $message = __(' Early Pricing', 'event_espresso'); } else { $message = ''; } $surcharge = ''; if ($result->surcharge > 0 && $result->event_cost > 0.0) { $surcharge = " + {$org_options['currency_symbol']}{$result->surcharge} " . $surcharge_text; if ($result->surcharge_type == 'pct') { $surcharge = " + {$result->surcharge}% " . $surcharge_text; } } //Using price ID $html .= '<option' . $selected . ' value="' . $result->id . '|' . $result->price_type . '">' . $result->price_type . ' (' . $org_options['currency_symbol'] . number_format($result->event_cost, 2) . $message . ') ' . $surcharge . ' </option>'; } $html .= '</select><input type="hidden" name="price_select" id="price_select-' . $event_id . '" value="true" />'; } else { if ($wpdb->num_rows == 1) { foreach ($results as $result) { // Addition for Early Registration discount if (early_discount_amount($event_id, $result->event_cost) != false) { $early_price_data = array(); $early_price_data = early_discount_amount($event_id, $result->event_cost); $result->event_cost = $early_price_data['event_price']; $message = sprintf(__(' (including %s early discount) ', 'event_espresso'), $early_price_data['early_disc']); } $surcharge = ''; if ($result->surcharge > 0 && $result->event_cost > 0.0) { $surcharge = " + {$org_options['currency_symbol']}{$result->surcharge} " . $surcharge_text; if ($result->surcharge_type == 'pct') { $surcharge = " + {$result->surcharge}% " . $surcharge_text; } } $message = isset($message) ? $message : ''; $html .= '<span class="event_price_label">' . __('Price:', 'event_espresso') . '</span> <span class="event_price_value">' . $org_options['currency_symbol'] . number_format($result->event_cost, 2) . $message . $surcharge . '</span>'; $html .= '<input type="hidden" name="price_id' . $multi_name_adjust . '" id="price_id-' . $result->id . '" value="' . $result->id . '" />'; } } else { if ($wpdb->num_rows == 0) { $html .= '<span class="free_event">' . __('Free Event', 'event_espresso') . '</span>'; $html .= '<input type="hidden" name="payment' . $multi_name_adjust . '" id="payment-' . $event_id . '" value="' . __('free event', 'event_espresso') . '" />'; } } } return $html; }
function event_espresso_get_final_price($price_id, $event_id = 0) { global $wpdb, $org_options; $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, event_cost, member_price, surcharge, surcharge_type FROM " . EVENTS_PRICES_TABLE . " WHERE id='" . $price_id . "' ORDER BY id ASC LIMIT 1"; } $results = $wpdb->get_results($sql); foreach ($results as $result) { if ($wpdb->num_rows >= 1) { if ($result->event_cost > 0.0) { $surcharge = number_format($result->surcharge, 2, '.', ''); //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 = number_format($result->event_cost * $result->surcharge / 100, 2, '.', ''); } $event_cost = $result->member_price == "" ? $result->event_cost + $surcharge : $result->member_price + $surcharge; // Addition for Early Registration discount if (early_discount_amount($event_id, $event_cost) != false) { $early_price_data = array(); $early_price_data = early_discount_amount($event_id, $event_cost); $event_cost = $early_price_data['event_price']; } } else { $event_cost = __('0.00', 'event_espresso'); } } else { if ($wpdb->num_rows == 0) { $event_cost = __('0.00', 'event_espresso'); } } } return empty($event_cost) ? 0 : $event_cost; }
function event_espresso_get_final_price($price_id, $event_id = 0) { do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, ''); 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'); } } } return empty($event_cost) ? 0 : $event_cost; }
function event_espresso_group_price_dropdown($event_id, $label = 1, $multi_reg = 0, $value = '') { global $wpdb, $org_options; do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, ''); /* * find out pricing type. * - If multiple price options, for each one * -- Create a row in a table with a name * -- qty dropdown * */ //Will make the name an array and put the time id as a key so we //know which event this belongs to $multi_name_adjust = $multi_reg == 1 ? "[{$event_id}]" : ''; $SQL = "SELECT ept.id, ept.event_cost, ept.surcharge, ept.surcharge_type, ept.price_type, edt.allow_multiple, edt.additional_limit "; $SQL .= "FROM " . EVENTS_PRICES_TABLE . " ept "; $SQL .= "JOIN " . EVENTS_DETAIL_TABLE . " edt ON ept.event_id = edt.id "; $SQL .= "WHERE event_id=%d ORDER BY ept.id ASC"; // filter SQL statement $SQL = apply_filters('filter_hook_espresso_group_price_dropdown_sql', $SQL); // get results $results = $wpdb->get_results($wpdb->prepare($SQL, $event_id)); if ($wpdb->num_rows > 0) { $attendee_limit = 1; //echo $label==1?'<label for="event_cost">' . __('Choose an Option: ','event_espresso') . '</label>':''; //echo '<input type="radio" name="price_option' . $multi_name_adjust . '" id="price_option-' . $event_id . '">'; ?> <table class="price_list"> <?php $available_spaces = get_number_of_attendees_reg_limit($event_id, 'number_available_spaces'); foreach ($results as $result) { //Setting this field for use on the registration form $_SESSION['espresso_session']['events_in_session'][$event_id]['price_id'][$result->id]['price_type'] = stripslashes_deep($result->price_type); // 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']; $message = __(' Early Pricing', 'event_espresso'); } $surcharge = ''; if ($result->surcharge > 0 && $result->event_cost > 0.0) { $surcharge = " + {$org_options['currency_symbol']}{$result->surcharge} " . $org_options['surcharge_text']; if ($result->surcharge_type == 'pct') { $surcharge = " + {$result->surcharge}% " . $org_options['surcharge_text']; } } ?> <tr> <td class="price_type"><?php echo $result->price_type; ?> </td> <td class="price"><?php if (!isset($message)) { $message = ''; } echo $org_options['currency_symbol'] . number_format($result->event_cost, 2) . $message . ' ' . $surcharge; ?> </td> <td class="selection"> <?php $attendee_limit = 1; $att_qty = empty($_SESSION['espresso_session']['events_in_session'][$event_id]['price_id'][$result->id]['attendee_quantity']) ? '' : $_SESSION['espresso_session']['events_in_session'][$event_id]['price_id'][$result->id]['attendee_quantity']; if ($result->allow_multiple == 'Y') { $attendee_limit = $result->additional_limit; if ($available_spaces != 'Unlimited') { $attendee_limit = $attendee_limit <= $available_spaces ? $attendee_limit : $available_spaces; } } event_espresso_multi_qty_dd($event_id, $result->id, $attendee_limit, $att_qty); ?> </td> </tr> <?php } ?> <tr> <td colspan="3" class="reg-allowed-limit"> <?php printf(__("You can register a maximum of %d attendees for this event.", 'event_espresso'), $attendee_limit); ?> </td> </tr> </table> <input type="hidden" id="max_attendees-<?php echo $event_id; ?> " class="max_attendees" value= "<?php echo $attendee_limit; ?> " /> <?php } else { if ($wpdb->num_rows == 0) { echo '<span class="free_event">' . __('Free Event', 'event_espresso') . '</span>'; echo '<input type="hidden" name="payment' . $multi_name_adjust . '" id="payment-' . $event_id . '" value="' . __('free event', 'event_espresso') . '">'; } } }
function event_espresso_group_price_dropdown($event_id, $label = 1, $multi_reg = 0, $value = '') { global $wpdb, $org_options; /* * find out pricing type. * - If multiple price options, for each one * -- Create a row in a table with a name * -- qty dropdown * */ //Will make the name an array and put the time id as a key so we //know which event this belongs to $multi_name_adjust = $multi_reg == 1 ? "[{$event_id}]" : ''; $results = $wpdb->get_results("SELECT ept.id, ept.event_cost, ept.surcharge, ept.surcharge_type, ept.price_type, edt.allow_multiple, edt.additional_limit\n FROM " . EVENTS_PRICES_TABLE . " ept\n JOIN " . EVENTS_DETAIL_TABLE . " edt\n ON ept.event_id = edt.id\n WHERE event_id='" . $event_id . "' ORDER BY ept.id ASC"); if ($wpdb->num_rows > 0) { $attendee_limit = 1; //echo $label==1?'<label for="event_cost">' . __('Choose an Option: ','event_espresso') . '</label>':''; //echo '<input type="radio" name="price_option' . $multi_name_adjust . '" id="price_option-' . $event_id . '">'; ?> <table class="price_list"> <?php $available_spaces = get_number_of_attendees_reg_limit($event_id, 'number_available_spaces'); foreach ($results as $result) { //Setting this field for use on the registration form $_SESSION['espresso_session']['events_in_session'][$event_id]['price_id'][$result->id]['price_type'] = $result->price_type; // Addition for Early Registration discount if (early_discount_amount($event_id, $result->event_cost) != false) { $early_price_data = array(); $early_price_data = early_discount_amount($event_id, $result->event_cost); $result->event_cost = $early_price_data['event_price']; $message = __(' Early Pricing', 'event_espresso'); } $surcharge = ''; if ($result->surcharge > 0 && $result->event_cost > 0.0) { $surcharge = " + {$org_options['currency_symbol']}{$result->surcharge} " . __('Surcharge', 'event_espresso'); if ($result->surcharge_type == 'pct') { $surcharge = " + {$result->surcharge}% " . __('Surcharge', 'event_espresso'); } } //echo '<option value="' . number_format($result->event_cost,2) . '|' . $result->price_type . '|' . $result->surcharge . '">' . $result->price_type . ' (' . $org_options['currency_symbol'] . number_format($result->event_cost,2) . $message . ') '. $surcharge . ' </option>'; ?> <tr> <td class="price_type"> <?php echo $result->price_type; ?> </td> <td class="price"> <?php if (!isset($message)) { $message = ''; } echo $org_options['currency_symbol'] . number_format($result->event_cost, 2) . $message . ' ' . $surcharge; ?> </td> <td class="selection"> <?php if ($result->allow_multiple == 'Y') { $attendee_limit = $result->additional_limit + 1; if ($available_spaces != 'Unlimited') { $attendee_limit = $attendee_limit <= $available_spaces ? $attendee_limit : $available_spaces; } event_espresso_multi_qty_dd($event_id, $result->id, $attendee_limit, empty($_SESSION['espresso_session']['events_in_session'][$event_id]['price_id'][$result->id]['attendee_quantity']) ? '' : $_SESSION['espresso_session']['events_in_session'][$event_id]['price_id'][$result->id]['attendee_quantity']); } else { $checked = $wpdb->num_rows == 1 || array_key_exists($result->id, $_SESSION['espresso_session']['events_in_session'][$event_id]['price_id']) && isset($_SESSION['espresso_session']['events_in_session'][$event_id]['price_id'][$result->id]['attendee_quantity']) ? ' checked="checked"' : ''; ?> <input type="radio" class="price_id" name="price_id[<?php echo $event_id; ?> ]" <?php echo $checked; ?> value="<?php echo $result->id; ?> " /> <?php } ?> </td> </tr> <?php } ?> <tr> <td colspan="3" class="reg-allowed-limit"><?php printf(__("You can register a maximum of %d attendees for this event.", 'event_espresso'), $attendee_limit); ?> </td> </tr> </table> <input type="hidden" id="max_attendees-<?php echo $event_id; ?> " class="max_attendees" value= "<?php echo $attendee_limit; ?> " /> <?php } else { if ($wpdb->num_rows == 0) { echo '<span class="free_event">' . __('Free Event', 'event_espresso') . '</span>'; echo '<input type="hidden" name="payment' . $multi_name_adjust . '" id="payment-' . $event_id . '" value="' . __('free event', 'event_espresso') . '">'; } } }