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


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;

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.

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3

Documentation for Event Espresso 4

Status: closed

Updated by  Josh 4 years, 7 months ago ago

Topic Tags

Tagged: , , ,

Notifications

This topic is: not resolved
Do NOT follow this link or you will be banned from the site!
[for="input_96_5_3"]
[for="input_96_5_3"]
[gravityform id=96 title=false description=false]
  • This field is for validation purposes and should be left unchanged.
[i]
[i]
[gravityform id=69 title=false description=false]
  • This field is for validation purposes and should be left unchanged.