Displaying information about events whose registration is not yet open

WordPress Event Management, Calendars & Registration Forums General Question Displaying information about events whose registration is not yet open

This topic contains 2 replies, has 2 voices, and was last updated by  Judy Kavanagh 7 years ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #30294

    I have customized the display of our workshops by indicating how many spots are left in a class. I put this in my single-event.php.

    <?php
    $now = new DateTime( ‘now’, eo_get_blog_timezone() );
    if (( eo_get_the_start( DATETIMEOBJ) ) > $now ) {
    if( (has_term( ‘Spinning’, ‘event-category’ )) or (has_term(‘Weaving’, ‘event-category’)) or (has_term( ‘Basketry’, ‘event-category’ )) or (has_term(‘Dyeing and Colour’, ‘event-category’) or (has_term(‘Felting’, ‘event-category’)) or (has_term( ‘Fibre Preparation’, ‘event-category’ )))){
    //This event is a workshop. Show how many tickets remain
    $remaining = eo_get_remaining_tickets_count( get_the_ID() );
    if( $remaining > 1 ){
    printf( ‘

    There are %d spots remaining in this workshop

    ‘, $remaining);
    }elseif( $remaining == 1 ){
    echo ‘

    Only one spot remaining!

    ‘;
    }elseif( $remaining == 0){
    echo ‘

    Sorry, this workshop is full. Get on a waiting list.

    ‘;
    }
    }
    }
    ?>

    However, for events whose registration period is not yet open it still “Sorry, this workshop is full…”

    After poking around in the codex and tutorials I still can’t figure out how to ask an event if registration is open. Can you direct me to the right code?

    And a question about this code. I pinched some of it from elsewhere. Why use printf for one line and echo for another?

    Thanks

    Judy Kavanagh
    #30295

    I tend to use printf when I need to escape values and echo if it’s a hard-coded string.

    As for why the above codes does not work for events which don’t have tickets yet, is because eo_get_remaining_tickets_count() only counts tickets which are currently on sale.

    What you could do is, in you single-event.php is:

    $tickets = eo_get_event_tickets_on_sale( get_the_ID() );
    

    If $tickets is empty then the event has not started yet (or has passed).

    Stephen Harris
    #30309

    Thanks Stephen. That works perfectly.

    Judy Kavanagh
Viewing 3 posts - 1 through 3 (of 3 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.