Support

Home Forums Event Espresso Premium event list price order

event list price order

Posted: May 19, 2020 at 7:09 am


mgregor

May 19, 2020 at 7:09 am

hi, i found this topic and i need to do the opposite. my ticket prices are showing in the order as entered and we’d prefer them to always sort by price, with the most expensive first). how can i modify this to work? i’m on ee3 (Version 3.1.37.17.P)

https://www.suzanenorthrop.com/upcoming-events/?ee=42

https://eventespresso.com/topic/event-list-prices-order/


mgregor

May 19, 2020 at 10:04 am

i’m also trying to get this to work.
https://eventespresso.com/topic/hide-sold-out-events-in-ee3/


Tony

  • Support Staff

May 20, 2020 at 9:07 am

Hi there,

The thread you linked to changes the price list function, but you linked directly to an event, that output doesn’t use a price list it uses a dropdown and therefor uses a different function.

So, may I ask is it the price dropdown function you are looking to change?

If so, are you using the ‘Event Espresso – Members Addon’ on the site? (Meaning you can set prices for logged out users and prices for logged in members)

i’m also trying to get this to work.
https://eventespresso.com/topic/hide-sold-out-events-in-ee3/

Ok, but we’ll need more details on what you are stuck on with the above.

The code is still available on that site and Josh’s fix still applies.


mgregor

May 20, 2020 at 9:53 am

it’s the order in my dropdown on the event registration page that i would like to have automatically sort from most expensive to least. right now they sort by order input. i am not using that plugin.


Tony

  • Support Staff

May 20, 2020 at 11:51 am

Ok, so for that you need to copy the event_espresso_price_dropdown function in:

\event-espresso\includes\functions\pricing.php

Line 396 – 453 (everything within the if (!function_exists('event_espresso_price_dropdown')) { ... } condition).

Add that to your custom functions plugin mentioned in the previous thread and then change:

$results = $wpdb->get_results( $wpdb->prepare("SELECT id, event_cost, surcharge, surcharge_type, price_type FROM " . EVENTS_PRICES_TABLE . " WHERE event_id='%d' ORDER BY id ASC", $event_id) );

to be:

$results = $wpdb->get_results( $wpdb->prepare("SELECT id, event_cost, surcharge, surcharge_type, price_type FROM " . EVENTS_PRICES_TABLE . " WHERE event_id='%d' ORDER BY event_cost DESC", $event_id) );

Inside your custom function.

That will sort the event prices in the dropdown by event cost highest -> lowest.


mgregor

May 21, 2020 at 8:20 am

ok! awesome! that’s working! as for the hiding sold out events?


Tony

  • Support Staff

May 21, 2020 at 8:24 am

You haven’t given any more details, so my answer is currently the same as above:

Ok, but we’ll need more details on what you are stuck on with the above.

The code is still available on that site and Josh’s fix still applies.

Have you added the code to your site and added Josh’s fix?

Note that thread hides sold-out events from the Table View Template add-on so I assume you are viewing that output?


mgregor

May 21, 2020 at 8:30 am

wait!? why does the exact same plugin not work on my live site, but it works on my staging site?

https://www.suzanenorthrop.com/upcoming-events/?ee=42
https://stage.suzanenorthrop.com/upcoming-events/?ee=42

they are literally the same code?


mgregor

May 21, 2020 at 8:40 am

i’ve cleared and deactivated my cache for the live site, but it’s still not seeing my custom plugin.


mgregor

May 21, 2020 at 8:40 am

to be clear, the plugin is active, but new sort isn’t sorting.


Tony

  • Support Staff

May 21, 2020 at 8:40 am

Sometimes load order matters with WordPress.

Deactivate Event Espresso and the custom functions plugin. Then reactivate (in this order) the custom functions plugin then Event Espresso.

Or, if you prefer not to do that, create a custom_functions.php file within:

/wp-content/uploads/espresso/

Then place the function within that file (remember to add an opening <?php tag to the file.

(You’ll need to remove the function from the custom functions plugin to use the above)

One issue with the above method is some ‘security’ plugins simply remove .php files found in /uploads/, or worse still, some leave the file there and just empty it.


mgregor

May 21, 2020 at 8:55 am

ok. the custom function in /uploads/espresso seemed to do it. weird. i am not using any addons, but was trying to hide the sold out ones from event_list.php for this type of list

https://www.suzanenorthrop.com/upcoming-events/


Tony

  • Support Staff

May 21, 2020 at 9:16 am

Ok, so that’s completely different to the thread you linked to above.

That’s using [EVENT_LIST] to output various lists, correct?

Copy event_list.php and event_list_display.php to:

/wp-content/uploads/espresso/templates/

Edit event_list.php and around line 288 you’ll have:

$event_id = $event->id;

Just after that add:

$open_spots = apply_filters('filter_hook_espresso_get_num_available_spaces', $event_id);
if($open_spots < 1) {
	continue;
}

That should remove sold-out events from the lists.

Note that the above increases the number of queries per event.


mgregor

May 21, 2020 at 9:26 am

well, no wonder it didn’t work when i tried. lol.

this worked like perfection. thank you 🙂

The support post ‘event list price order’ 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