Show # of tickets remaining

This topic contains 4 replies, has 4 voices, and was last updated by  Evert 4 years, 6 months ago.

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

    Could we have an option to add a shortcode to show how many tickets for each specific event are remaining or an option within the settings to turn such a feature on or off?

    It can get rather irritating if someone wants to book 4 tickets and there are only 3 remaining.

    I know there are options to do this within the code such as :

    //In your single-event.php template:
    $remaining = eo_get_remaining_tickets_count( get_the_ID() );
    if( $remaining > 1 ){
     printf( 'Hurry, only %d tickets remaining', $remaining );
     }elseif( $remaining == 1 ){
     echo 'Only one ticket remaining!';
    }else{
     echo 'Sorry, there are not tickets available';
    }
    

    but when I try and implement it, I’m getting nothing showing in the actual events page

    Anthony

    Anthony Didsbury
    #34558

    Hi Anthony,

    Is this a recurring event, and if so, are you selling tickets for individual occurrences or the series?

    Stephen Harris
    #34565

    Hi Stephen, no its for individual events.

    Anthony Didsbury
    #36418

    Hello,

    Have you got any feedback about this request ?

    That’s a feature I’m interested in as well as keeping the tickets displayed with “sold-out” mention instead of removing them from the list.

    Best regards,

    Jef

    zwazo
    #36422

    It may not be the best way but it works for me for a single event.

    I have put it in the metablock so that it is standard information with, the date, tag, venue and map.

  • <?php $remaining = eo_get_remaining_tickets_count( get_the_ID() );
  • if( $remaining > 1 ){
    printf( ‘Beschikbare tickets: nog %d te reserveren’, $remaining );
    }elseif( $remaining == 1 ){
    echo ‘Nog slechts 1 ticket beschikbaar!’;
    }else{
    echo ‘Beschikbare tickets: Uitverkocht!’;
    } ?>

  • <?php esc_html_e( ‘Date’, ‘eventorganiser’ );?>: <?php echo eo_format_event_occurrence();?>
  • <?php } ?>

        <?php if ( eo_get_venue() ) {
            $tax = get_taxonomy( 'event-venue' ); ?>
            
  • <?php echo esc_html( $tax->labels->singular_name ) ?>: "> <?php eo_venue_name();?>
  • <?php } ?>

    <?php if ( get_the_terms( get_the_ID(), ‘event-category’ ) && ! is_wp_error( get_the_terms( get_the_ID(), ‘event-category’ ) ) ) { ?>

  • <?php esc_html_e( ‘Categories’, ‘eventorganiser’ ); ?>: <?php echo get_the_term_list( get_the_ID(),’event-category’, ”, ‘, ‘, ” ); ?>
  • <?php } ?>

        <?php if ( get_the_terms( get_the_ID(), 'event-tag' ) && ! is_wp_error( get_the_terms( get_the_ID(), 'event-tag' ) ) ) { ?>
            
  • <?php esc_html_e( 'Tags', 'eventorganiser' ); ?>: <?php echo get_the_term_list( get_the_ID(), 'event-tag', '', ', ', '' ); ?>
  • <?php } ?>

    The extra code itself is

  • <?php $remaining = eo_get_remaining_tickets_count( get_the_ID() );
  • if( $remaining > 1 ){
    printf( ‘Beschikbare tickets: nog %d te reserveren’, $remaining );
    }elseif( $remaining == 1 ){
    echo ‘Nog slechts 1 ticket beschikbaar!’;
    }else{
    echo ‘Beschikbare tickets: Uitverkocht!’;
    } ?>

    Perhaps this will help you.

Evert