Support

Home Forums Event Espresso Premium EE4 Upcoming Events Widget to show ticket price (lowest if more than one)

EE4 Upcoming Events Widget to show ticket price (lowest if more than one)

Posted: March 23, 2015 at 7:39 am

Viewing 1 reply thread


tom2015

March 23, 2015 at 7:39 am

I have EEW_Upcoming_Events in my custom plugin and it works fine.

I see that the events are obtained via:

$events = EE_Registry::instance()->load_model( ‘Event’ )->get_all( …….

How can I also get and display the price of the upcoming events from here?

Many thanks.


Josh

  • Support Staff

March 25, 2015 at 4:49 pm

Hi Tom,

While there isn’t a template tag that displays one price for an event, there is a template tag that will display a list of all available tickets for one event. So for example, you could add the following to your widget code:

echo espresso_event_tickets_available( $event->ID() );

Then it will output a formatted list of tickets with their prices.

If you want to dial down further and return only a lowest price with no ticket names, it’s possible to do that too. Some example code that includes use of the event_tickets_available() helper view method follows:

$tickets = EEH_Event_View::event_tickets_available( $event->ID() );
$ticket_prices = array();
foreach ($tickets as $ticket ) {
    array_push($ticket_prices, $ticket->price()); 
}
$lowest_price = min($ticket_prices);
echo 'Starting from: $' . $lowest_price;
Viewing 1 reply thread

The support post ‘EE4 Upcoming Events Widget to show ticket price (lowest if more than one)’ 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