show total and booked spaces in the "all events" view

WordPress Event Management, Calendars & Registration Forums General Question show total and booked spaces in the "all events" view

This topic contains 2 replies, has 2 voices, and was last updated by  David Bühler 4 months ago.

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

    Hi!

    It would be great if one could activate another row in the “all events” view, showing the total and booked spaces for every listed event, for example:
    36 / 100

    Which means 36 of 100 are booked. Is it possible to do that with some extra code?

    Many thanks & cheers
    David

    David Bühler
    #39852

    Hi David,

    This isn’t provided for in the plug-in by default as it wouldn’t scale well for recurring events where you are selling tickets to individual occurrences.

    The following should work but assumes you are selling by series not occurrence:

    <?php
    add_filter( 'manage_edit-event_columns', function($columns){
        $columns['_bookings'] = "Bookings";
        return $columns;
    } );
    
    
    add_action( 'manage_event_posts_custom_column', function($column, $event_id ) {
        global $post;
    
        if ($column !== '_bookings') {
            return;
        }
    
        $confirmed = eventorganiser_get_bookings( array( 
            'status'        => eo_get_confirmed_booking_statuses(), 
            'fields'        =>'count_tickets', 
            'occurrence_id' => 0, 
            'event_id'      => $event_id 
        ));
        $capacity = eventorganiser_get_capacity( $event_id, 0 );
    
        echo "$confirmed / $capacity";
    
    }, 10, 2);
    
    Stephen Harris
    #39858

    That’s great, many thanks for your quick answer! It works perfectly.

    Cheers, David

    David Bühler
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.