Support

Home Forums Event Espresso Premium Repeated espresso_event_tickets_available() template tag values

Repeated espresso_event_tickets_available() template tag values

Posted: November 16, 2016 at 6:14 am


George

November 16, 2016 at 6:14 am

Hi,

I’m experiencing a weird issue while using espresso_event_tickets_available() template tag on content-espresso_events-shortcode.php template page.

My event has multiple date times (Ex. Tuesdays & Thursdays) which the same tickets (Ex. Single Entry & Monthly Entry tickets) applied to each date/time.

My issue is: When using the espresso_event_tickets_available() tag, i expected it to return distinct values of the available tickets for each single event however, it returns a repeated list of the available tickets as they are assigned to each date/time for each single event. (Ex. If I have 2 available tickets and 8 different date/times for a single event, espresso_event_tickets_available() returns the available tickets for that single event 8 times)

Follow this link to see the issue.

Also see screenshot:
Screenshot

Please can you help me resolve this duplicate issue or is there a better way to do this or I’m i doing it all wrong?

Please help!!

Thanks.


Josh

  • Support Staff

November 16, 2016 at 7:46 am

Can you post the code you’re working with in a paste bin or gist, then link here, so we have a better idea of what’s going on?


George

November 16, 2016 at 7:57 am

Hi Josh,

Here’s the pastebin URL for my modifed content-espresso_events-shortcode.php template

http://pastebin.com/GsiRhUjr


Josh

  • Support Staff

November 16, 2016 at 8:05 am

Did you follow the instructions in the PHP comment starting on line 14? It doesn’t look that way since the the call to the_content() hasn’t been commented out.


George

November 17, 2016 at 5:49 am

Hi Josh,

I have fixed the template file, commented on the_content() but still not working, the problem is still there


Tony

  • Support Staff

November 17, 2016 at 4:07 pm

Hi there,

Follow this link to see the issue.

The site is in maintenance/coming soon mode so we can’t view this.

The problem is not the call to the_content(), its happening because espresso_event_tickets_available() loops over all of the datetimes within an event and adds any available tickets from each datetime to an array which is used for the output of the tickets. It does not check for unique tickets and just adds any available tickets from each datetime.

As your event has the same tickets assigned to multiple datetimes you end up with the same tickets multiple times.

espresso_event_tickets_available() is a pluggable function so you can copy the function to your themes functions.php file to override it.

After the tickets are pulled in you can use something like:

$tickets = array_unique( $tickets, SORT_REGULAR);

To filter the array so it only contains 1 of each ticket object.


George

November 18, 2016 at 2:46 am

Thanks Tony, Exactly my point. Your solution worked flawlessly.

Thanks all (Josh, Tony, …) for your help.

The support post ‘Repeated espresso_event_tickets_available() template tag values’ 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