Support

Home Forums Event Espresso Premium Event List: Show Price before Surcharge

Event List: Show Price before Surcharge

Posted: November 15, 2013 at 1:08 pm

Viewing 10 reply threads


Devon Boorman

November 15, 2013 at 1:08 pm

Hello

I looked through the forum and could not find this topic. I would like to show the price before surcharge on the EVENT_LIST page. That is, if an item is $10 with 5% surcharge, I would like the event list page to show $10, not $10.50. Then when they register they can see the full price in their cart total. I’ve already tweaked the PHP file with a few nice changes, so cutting a pasting code is no problem. Thanks for your help.

Greg Reimer
Academie Duello


Jonathan Wilson

  • Support Staff

November 17, 2013 at 3:03 pm

Hi Devon,

My EVENT_LIST page doesn’t show a surcharge. The surcharge only appears on the event page. I’ve tried to make it appear in the Event List, but cannot. I’m not sure what settings your have. What add-ons are you using?


Devon Boorman

November 19, 2013 at 12:31 am

I’m working to solve a problem with the way event prices display.

http://staging.eventespresso.com/forums/2012/04/standard-pricing-not-consistant/

When I do not use the substituted code, the event price does not include the surcharge and shows $10. But it does not show the price at the top (first) of the list.

When I do use the substituted code so that the top (first) price is always shown, it includes the surcharge amount ($10.50) in the price.

So… is there a way I can show the top (first) price in the list and have it not include the surcharge amount? Thanks.

http://www.academieduello.com/school/workshops/workshops-calendar/

Here’s the page I’m working with (if that helps). Prices that show $63 are actually $60 items that have 5% tax included. I want to show just the $60, which is the first price in the list.

Greg


Dean

  • Support Staff

November 19, 2013 at 2:22 am

Hi,

Not with that shortcode or even the base function it uses as it combines all the costs together.

The only way I can think of getting what you need is via an SQL query.

An alternative option would be to show a price list or price range on the event list:

List
https://gist.github.com/sethshoultes/ab1e992668cf3166a686
Range
https://gist.github.com/sethshoultes/f05ae8b0c2f549a94d67


Devon Boorman

November 19, 2013 at 10:40 am

I’m not too swift on creating SQL queries. Can you offer one? Thanks.


Sidney Harrell

  • Support Staff

November 19, 2013 at 11:26 am

You can use the code below:

You can add this code to one of the following:
1 – Your theme’s functions.php file. It may get overwritten the next time you update your theme.
2 – The EE custom files add-on in the custom_functions.php file.
3 – Use this blank plugin to hold the custom function.


Devon Boorman

November 19, 2013 at 11:27 am

I’ll try it out. Much appreciated! Thanks.


Devon Boorman

November 19, 2013 at 11:34 am

Well, when I paste it into functions.php it takes down my entire site. Blank white page.

?


Dean

  • Support Staff

November 20, 2013 at 3:07 am

It is not recommended to test out code changes on a live site, as minor errors in code (we are after all only human) can crash a site.

If you have not done so already, please edit the file where you added the code via FTP and remove the code.

I would suggest using the Plugin idea Sidney said.

Also try this code, it has been modified slightly to remove the error.

function espresso_return_single_price_sans_surcharge($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 event_cost 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) {
					$event_cost = $result->event_cost;

				} else {
					$event_cost = '0.00';
				}
			}
		} else {
			$event_cost = '0.00';
		}
				$event_cost = number_format( $event_cost, 2, '.', '');

		return $event_cost;
}


function get_espresso_price_sans_surcharge_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_sans_surcharge($event_id, $number);
	$buffer = ob_get_contents();
	ob_end_clean();
	return $buffer;
}
add_shortcode('EVENT_PRICE_SANS_SURCHARGE', 'get_espresso_price_sans_surcharge_sc');

Something like this would be used in the event_list_display.php

<?php
echo  $org_options['currency_symbol'] . do_shortcode('[EVENT_PRICE_SANS_SURCHARGE event_id="' . $event_id . '" number="0"]');
?>

Please note, that if you do not understand the code or how to add the code, you may need to refer to a web developer for assistance.


Devon Boorman

November 20, 2013 at 9:06 am

Thanks, that did it. You’ve been extremely helpful. Much appreciated.

Greg


Sidney Harrell

  • Support Staff

November 20, 2013 at 11:42 am

Sorry, lost track of the starting and closing braces. I’ve cleaned up the gist on github for any future viewers of this thread.

Viewing 10 reply threads

The support post ‘Event List: Show Price before Surcharge’ 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 - Staging Server