Display available ticket count after re-occuring dates

WordPress Event Management, Calendars & Registration Forums General Question Display available ticket count after re-occuring dates

This topic contains 4 replies, has 3 voices, and was last updated by  Lorie Travis 6 years, 11 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #11016

    Hi Stephen,

    Hope you can help with this.
    I need to display the number of currently available tickets after each upcoming event date on a single event page. I have created my own versions of the single-event.php and the event-meta-event-single.php files which are stored in my theme folder as recommended.

    I have included my effort below. I have placed this code in the event-meta-event-single.php file as that’s where the dates are generated.

    What I’m trying to achieve will look like this:

    Upcoming Dates:
    – 7th June, 2014 (12 spaces left)
    – 20th September, 2014 (6 spaces left)
    – 15th November, 2014 (3 spaces left)

    However, at the moment, it’s just adding up the total number of tickets available and putting that figure after each upcoming date.

    Here is my code (event-meta-event-single.php)

    <

    pre>
    <?php if( eo_reoccurs() ){
    //Event reoccurs – display dates.
    $upcoming = new WP_Query(array(
    ‘post_type’=>’event’,
    ‘event_start_after’ => ‘today’,
    ‘posts_per_page’ => -1,
    ‘event_series’ => get_the_ID(),
    ‘group_events_by’=>’occurrence’//Don’t group by series
    ));

    if( $upcoming->have_posts() ): ?>

                    
  • <?php _e('Upcoming Dates','eventorganiser'); ?>: <ul id="eo-upcoming-dates"> <?php while( $upcoming->have_posts() ): $upcoming->the_post(); ?> <?php $future_occurrences = eo_get_the_future_occurrences_of( get_the_ID() ); if( $future_occurrences ){ foreach( $future_occurrences as $occurrence_id => $dates ){ $remaining = eo_get_remaining_tickets_count( get_the_ID(), $occurrence_id ); } } ?>
  • <?php eo_the_start('jS F, Y') ?> <?php printf($remaining) ?>
  • <?php unset($remaining); ?> <?php endwhile; ?>
    Paul Oaten
    #11017

    Hope the above code snippet makes sense – didn’t display as expected!

    Paul Oaten
    #11023

    Hi Paul,

    No worries ;).

    In the above code you are already querying future dates, and then inside that while loop getting future dates again. The foreach loop means that $remaining is then set to the number of remaining tickets for the last date for that event. That’s why the number comes out the same for each date.

    By default the event-meta-event-single.php template looks like this:

     <li> <?php eo_the_start($date_format) ?></li>

    If you change that to

    <li> <?php echo eo_get_the_start($date_format) . ' (' . eo_get_remaining_tickets_count( get_the_ID(), $post->occurrence_id ).' spaces left)'; ?></li>

    then that’ll print the number of tickets enxt to each date.

    Stephen Harris
    #11032

    Perfect – thanks for the guidance!

    Paul Oaten
    #30106

    Hi Stephen,

    The line of code you refer to by default does not exist in my template php file. I would like to achieve the same results as Paul but since I cannot find that piece of code to replace with your amended code, I am stuck. Please advise.

    Thanks,
    Lorie

    Lorie Travis
Viewing 5 posts - 1 through 5 (of 5 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.