Home › Forums › Ticket Products › Event Tickets Plus › Trying to display multiple ticket prices
- This topic has 7 replies, 3 voices, and was last updated 10 years, 9 months ago by
Leah.
-
AuthorPosts
-
January 26, 2015 at 4:18 am #937507
liblogger
ParticipantHi there,
We have events with different ticket prices – usually Full price and Subsidised, or Full price and Free – and I’ve been trying to get these prices to display correctly in the event pages.
Initially, I couldn’t get the snippet here: https://theeventscalendar.com/knowledgebase/filtering-to-show-woocommerce-tickets-prices/ to work at all, but I eventually realised that if I removed the initial check to see if the cost was empty, the filter works for events with full price and subsidised tickets. However, it doesn’t display correctly when one of the tickets is free – in this case, it only displays the full price ticket.
I want to check that a) changing
if ( empty($cost) && class_exists('TribeWooTickets') )toif ( class_exists('TribeWooTickets') )isn’t going to do anything catastrophic elsewhere, and b) if there’s a way to display the price range as Free – £N rather than just £N.January 26, 2015 at 10:13 am #937713Barry
MemberHi!
Except that you wish to display a price range (rather than a single ticket price) you shouldn’t need the snippet referenced in the KB article you linked to – which I think may be in need of some revision.
Would something like this work for you instead?
add_filter( 'tribe_get_cost', 'show_ranged_ticket_costs', 20, 3 ); function show_ranged_ticket_costs( $cost, $event_id, $formatted ) { if ( ! tribe_events_has_tickets( $event_id ) ) return $cost; $min = $max = null; foreach ( TribeEventsTickets::get_all_event_tickets( $event_id ) as $ticket ) { $min = ( $ticket->price < $min || null === $min ) ? $ticket->price : $min; $max = ( $ticket->price > $max ) ? $ticket->price : $max; } if ( null === $min ) return $cost; $formatted_min = ( '0' === $min ) ? 'Free' : tribe_format_currency( $min ); if ( $min === $max ) return $formatted ? $formatted_min : $min; return $formatted ? $formatted_min . ' – ' . tribe_format_currency( $max ) : "$min – $max"; }Remember also that we’re always on the look out for new feature requests!
If you’d like to propose support for this sort of feature “out of the box” please do feel free to post a request – or add your support to any suitable existing request – over on our UserVoice page 🙂
I hope that helps.
January 27, 2015 at 3:22 am #937979liblogger
ParticipantHi Barry, thanks for the quick response.
That does seem to work – the only thing is that if we only have free tickets, it doesn’t display anything, but I think that was the default display anyway?
I’ll look at posting a feature request – seems like an obvious thing to have!
January 27, 2015 at 10:07 am #938166Barry
MemberFor that last issue I’m going to go ahead and log a bug report in any case, so you don’t need to post a feature request 🙂
The problem isn’t with the snippet – it is the fact that in the default single-event.php template it treats “0” (free) and “” (no cost) as one and the same – and it only causes the cost to be displayed if the value is something other than those.
With that in mind, an easy fix could be to override single-event.php and change this line (approx line 34):
<?php if ( tribe_get_cost() ) : ?>To:
<?php if ( '' !== tribe_get_cost() ) : ?>Would that work for you?
January 28, 2015 at 5:34 am #938420liblogger
ParticipantThe missing ‘Free’ isn’t too much of a problem for us at the moment – we have more unpaid events than paid events, so I may just add a line across the site to say that all events are free unless otherwise indicated. The display of the price range – when used – was more pressing!
I’ll make a note of the possible template edit, though. Thank you 🙂
January 28, 2015 at 6:59 am #938446Barry
MemberMy pleasure 🙂
I’ll go ahead and close out this topic in that case but of course if anything else crops up please don’t hesitate to open a new topic and let us know – one of the team will be only too happy to help.
Thanks again!
May 28, 2015 at 11:53 am #965765Leah
MemberHi there,
Thanks again for your post. We wanted to get in touch and let you know that although we weren’t able to address this issue in our upcoming 3.10 release, it is still very much a priority. We have a ticket in our system and will be investigating a solution for a future version. Thank you for your patience and support while we work on this!
Cheers,
The Events Calendar TeamJuly 20, 2015 at 12:12 pm #987982Leah
MemberHello,
Thank you again for bringing this issue to our attention. We’re happy to say that we have added a fix for this into our upcoming version 3.11 release. Keep an eye on your Updates page for the new version. If you have any trouble with the update (or are still seeing this problem after you update) please start a new thread and we’d be happy to help out.
Thank you for your patience while we got this release ready to go!
Best,
Leah
and the rest of The Events Calendar team -
AuthorPosts
- The topic ‘Trying to display multiple ticket prices’ is closed to new replies.
