';
break;
case 'NotCheckedin':
echo '
';
break;
case 'Completed':
echo '
';
break;
case 'Pending':
echo '
';
break;
case 'Payment Declined':
echo '
';
break;
default:
echo '
';
break;
}
}
//Retturns the first price assocaited with an event. If an event has more that one price, you can pass the number of the second price.
if (!function_exists('espresso_return_price')) {
function espresso_return_single_price($event_id, $number=0) {
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
global $wpdb, $org_options;
$number = $number == 0 ? '0,1' : $number . ',' . $number;
$results = $wpdb->get_results("SELECT id, event_cost, surcharge, surcharge_type FROM " . EVENTS_PRICES_TABLE . " WHERE event_id='" . $event_id . "' ORDER BY id ASC LIMIT " . $number);
if ($wpdb->num_rows > 0) {
foreach ($results as $result) {
if ($result->event_cost > 0.00) {
// is there a surcharge ???
if ( $result->surcharge > 0 ) {
if ( 'flat_rate' == $result->surcharge_type ) {
$event_cost = $result->event_cost + $result->surcharge;
} else {
$event_cost = $result->event_cost + ( $result->event_cost * $result->surcharge / 100 );
}
} else {
// no surcharge
$event_cost = $result->event_cost;
}
$event_cost = number_format( $event_cost, 2, '.', '');
#$event_cost = $result->surcharge > 0.00 && $result->event_cost > 0.00 ? $result->event_cost + number_format($result->event_cost * $result->surcharge / 100, 2, '.', '') : $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'];
}
} else {
$event_cost = '0.00';
}
}
} else {
$event_cost = '0.00';
}
return $event_cost;
}
}
/*
Returns the price of an event
*/
if (!function_exists('event_espresso_get_price')) {
function event_espresso_get_price($event_id) {
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
global $wpdb, $org_options;
$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 LIMIT 1");
$surcharge = '';
$surcharge_text = isset($org_options['surcharge_text']) ? $org_options['surcharge_text'] : __('Surcharge', 'event_espresso');
foreach ($results as $result) {
if ($wpdb->num_rows == 1) {
if ($result->event_cost > 0.00) {
$event_cost = $org_options['currency_symbol'] . $result->event_cost;
if ($result->surcharge > 0 && $result->event_cost > 0.00) {
$surcharge = " + {$org_options['currency_symbol']}{$result->surcharge} " . $surcharge_text;
if ($result->surcharge_type == 'pct') {
$surcharge = " + {$result->surcharge}% " . $surcharge_text;
}
}
// 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 = sprintf(__(' (including %s early discount) ', 'event_espresso'), $early_price_data['early_disc']);
//$surcharge = ($result->surcharge > 0.00 && $result->event_cost > 0.00)?" +{$result->surcharge}% " . __('Surcharge','event_espresso'):'';
$event_cost = '' . $org_options['currency_symbol'] . number_format($result->event_cost, 2) . $message . '';
}
$event_cost .= '';
} else {
$event_cost = __('Free Event', 'event_espresso');
}
} else if ($wpdb->num_rows == 0) {
$event_cost = __('Free Event', 'event_espresso');
}
}
return $event_cost . $surcharge;
}
}
/*
Returns the final price of an event
*
* @params int $price_id
* @params int $event_id
*/
if (!function_exists('event_espresso_get_final_price')) {
function event_espresso_get_final_price($price_id, $event_id = 0) {
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
global $wpdb;
$results = $wpdb->get_results("SELECT id, event_cost, surcharge, surcharge_type FROM " . EVENTS_PRICES_TABLE . " WHERE id='" . $price_id . "' ORDER BY id ASC LIMIT 1");
$event_cost = 0.00;
foreach ($results as $result) {
if ($wpdb->num_rows >= 1) {
if ($result->event_cost > 0.00) {
$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 = 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($event_cost * $result->surcharge / 100, 2, '.', '');
}
} else {
$event_cost = 0.00;
}
} else if ($wpdb->num_rows == 0) {
$event_cost = 0.00;
}
}
if (empty($surcharge))
$surcharge = 0;
$event_cost = $event_cost + $surcharge;
return empty($event_cost) ? 0 : $event_cost;
}
}
//Get the early bird pricing
if (!function_exists('early_discount_amount')) {
function early_discount_amount($event_id, $event_cost, $message='') {
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
global $wpdb, $org_options;
//$message = ' ' . __('Early Pricing','event_espresso');
$eventdata = $wpdb->get_results("SELECT early_disc, early_disc_date, early_disc_percentage FROM " . EVENTS_DETAIL_TABLE . " WHERE id='" . $event_id . "' LIMIT 1");
if ((strlen($eventdata[0]->early_disc) > 0) && (strtotime($eventdata[0]->early_disc_date) > strtotime(date("Y-m-d")))) {
$early_price_display = $eventdata[0]->early_disc_percentage == 'Y' ? $eventdata[0]->early_disc . '%' : $org_options['currency_symbol'] . $eventdata[0]->early_disc;
if ($eventdata[0]->early_disc_percentage == 'Y') {
$pdisc = $eventdata[0]->early_disc / 100;
$event_cost = $event_cost - ($event_cost * $pdisc);
} else {
// Use max function to prevent negative cost when discount exceeds price.
$event_cost = max(0, $event_cost - $eventdata[0]->early_disc);
}
//$extra = " " . $message;
$early_price_data = array('event_price' => $event_cost, 'early_disc' => $early_price_display);
return $early_price_data;
} else {
return false;
}
}
}
//Creates dropdowns if multiple prices are associated with an event
if (!function_exists('event_espresso_price_dropdown')) {
function event_espresso_price_dropdown($event_id, $label = 1, $multi_reg = 0, $value = '') {
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
//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 ? '' : '';
$html .= '';
} else if ($wpdb->num_rows == 1) {
foreach ($results as $result) {
// 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 = sprintf(__(' (including %s early discount) ', 'event_espresso'), $early_price_data['early_disc']);
}
$surcharge = '';
if ($result->surcharge > 0 && $result->event_cost > 0.00) {
$surcharge = " + {$org_options['currency_symbol']}{$result->surcharge} " . $surcharge_text;
if ($result->surcharge_type == 'pct') {
$surcharge = " + {$result->surcharge}% " . $surcharge_text;
}
}
$message = isset($message) ? $message : '';
$html .= '' . __('Price:', 'event_espresso') . ' ' . $org_options['currency_symbol'] . number_format($result->event_cost, 2) . $message . $surcharge . '';
$html .= '';
}
} else if ($wpdb->num_rows == 0) {
$html .= '' . __('Free Event', 'event_espresso') . '';
$html .= '';
}
return $html;
}
}
//This function gets the first price id associated with an event and displays a hidden field.
function espresso_hidden_price_id($event_id) {
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
global $wpdb, $org_options;
$wpdb->get_results("SELECT id FROM " . EVENTS_PRICES_TABLE . " WHERE event_id='" . $event_id . "' LIMIT 0,1 ");
$num_rows = $wpdb->num_rows;
if ($num_rows > 0) {
return '';
} else {
return '