adasch
July 18, 2019 at 9:07 am
Hi,
I use this code to echo the price for an available ticket
<?php echo espresso_event_tickets_available($post->ID, false, true); ?>
I have ONE event with 4 dates (1 is in the past, 3 are upcomming).
So what I get is three times the price, like
– 123€
– 123€
– 123€
I guess it’s because there are three dates left, but as it is just ONE ticket, I’d like to show the price only once.
Did I misuse espresso_event_tickets_available() for this purpose?
thanks!
Tony
July 18, 2019 at 9:19 am
Add New Note to this Reply
Hi there,
I think so, yes.
Can you link me to the event so I can see your setup?
adasch
July 18, 2019 at 9:51 am
Add New Note to this Reply
This reply has been marked as private.
adasch
July 18, 2019 at 9:52 am
Add New Note to this Reply
This reply has been marked as private.
adasch
July 18, 2019 at 9:54 am
Add New Note to this Reply
This reply has been marked as private.
Josh
July 18, 2019 at 2:48 pm
Add New Note to this Reply
Hi,
If you follow the source of espresso_event_tickets_available() you’ll note that it loops through all the datetimes.
What you could do instead is get the related ticket object for the event and get its price. e.g.
$event = EEH_Event_View::get_event($post->ID);
$html = '';
$tickets = array();
if ($event instanceof EE_Event) {
$tickets = $event->tickets();
}
foreach ( $tickets as $ticket ) {
if ( $ticket instanceof EE_Ticket ) {
$html .= $ticket->price(); // you could use money_format() or similar here
}
}
echo $html;
adasch
July 19, 2019 at 2:09 am
Add New Note to this Reply
thank you (again) 🙂