Support

Home Forums Event Espresso Premium Event Pricing Displaying Inconsistently

Event Pricing Displaying Inconsistently

Posted: July 26, 2015 at 10:21 am


Greg Dietrich

July 26, 2015 at 10:21 am

How can we get our event pricing to display consistently? Take a look at this screenshot: http://d.pr/i/13y6j

On the top event, it shows surcharge & discounted rate. On the bottom event it doesn’t show a surcharge or a $5 discount if registered by a certain date…though, we have those items set on the backend (http://d.pr/i/yKxh & http://d.pr/i/1jZbE).

I’m using EE3


Greg Dietrich

July 26, 2015 at 10:21 am

Sorry…this is the website: http://eventsignup.org/event-registration/


Josh

  • Support Staff

July 27, 2015 at 11:30 am

Hi Greg,

If you step through the code that outputs the price list on the event list, you’ll note it only displays the surcharge and early discount info if there’s more than one price for an event.

You can change this by copying the entire event_espresso_price_list function from /event-espresso/includes/functions/pricing.php into your functions file. Then you change the line within your copy of the function from:
if ($wpdb->num_rows > 1) {
to:
if ($wpdb->num_rows > 0) {


Greg Dietrich

July 27, 2015 at 11:49 am

OK, I did this…at least I think I did this. I know have this in my functions.php file:

if (!function_exists('event_espresso_price_list')) {
 
	function event_espresso_price_list($event_id) {
		$html = '';
		global $wpdb, $org_options;
		$sql = "SELECT id, event_cost, surcharge, surcharge_type, price_type";
		$order_by = 'event_cost';
		$member_event = FALSE;
		$surcharge_text = isset($org_options['surcharge_text']) ? $org_options['surcharge_text'] : __('Surcharge', 'event_espresso');
		if ( function_exists('espresso_members_installed') && espresso_members_installed() == true && is_user_logged_in() ) {
			$sql .= ", member_price, member_price_type ";
			$member_event = TRUE;
			$order_by = 'member_price';
		}
		$sql .= " FROM " . EVENTS_PRICES_TABLE . " WHERE event_id='%d' ORDER BY " . $order_by . " ASC";
		$results = $wpdb->get_results( $wpdb->prepare($sql, $event_id) );
		if ($wpdb->num_rows > 0) {	
			//Create a dropdown of prices
			$html .= '<span class="'.espresso_template_css_class('section_title','section-title',false).'">'. __(' Prices:', 'event_espresso').'</span>';
			$html .= '<ul id="price-list-' . $event_id . '" class="'.espresso_template_css_class('espresso_price_list','espresso-price-list',false).'">';
		 
			foreach ($results as $result) {
				if ($member_event == TRUE) {
					$result->event_cost = $result->member_price;
					$result->price_type = $result->member_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');
				} else {
					$message = '';
				}
		 
				$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;
					}
				}
				$html .= '<li>' . stripslashes_deep($result->price_type) . ' (' . $org_options['currency_symbol'] . number_format($result->event_cost, 2) . $message . ') ' . $surcharge . ' </li>';
			}
			$html .= '</ul>';
		}else{
			if ($member_event == TRUE) {
				$event_cost = $wpdb->last_result[0]->member_price;
				$price_type = $wpdb->last_result[0]->member_price_type;
			}else{
				$event_cost = $wpdb->last_result[0]->event_cost;
				$price_type = $wpdb->last_result[0]->price_type;
			}
				$html .= '<p><span class="'.espresso_template_css_class('section_title','section-title',false).'">'. __(' Price:', 'event_espresso').'</span> ' . $price_type . ' ' . $org_options['currency_symbol'] . number_format($event_cost, 2) . '</p>';
		}
		echo $html;
		return;
	}
}
add_action('action_hook_espresso_price_list', 'event_espresso_price_list', 20, 2);

I don’t see a difference on my page for the pricing: http://d.pr/i/RbFG


Josh

  • Support Staff

July 27, 2015 at 2:46 pm

Load order is important when using pluggable functions. If your code loads after Event Espresso’s code loads, your modification will not load. For example, if your functions file is also your theme’s functions.php file, you can copy the function to /wp-content/uploads/espresso/custom_functions.php. Event Espresso 3 will check there first for custom functions.


Greg Dietrich

July 27, 2015 at 2:51 pm

OK, that looks to do the trick. Thanks.


Josh

  • Support Staff

July 28, 2015 at 8:35 am

You’re welcome.

The support post ‘Event Pricing Displaying Inconsistently’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso