Support

Home Forums Event Espresso Premium Display the status of events in table view

Display the status of events in table view

Posted: July 29, 2021 at 9:07 am

Viewing 3 reply threads


infrasolutions

July 29, 2021 at 9:07 am

I’m working on some event table customization in order to provide students with more information at a glance and want to add the status of the event in the table.

I found this thread, and it worked well for customizing the link for cancelled and postponed events. https://eventespresso.com/topic/events-not-showing-canceled-or-rescheduled/

I’d like to know if there is a way to distinguish between upcoming events where ticket sales have started (are open) and where ticket sales have not started yet as well as events that are full with a wait list and events where even the wait list is full.

The thought is that I’d like to have the registration link indicate ‘Register’ for events where registration is open, and ‘More Info’ for events where ticket sales haven’t started yet as well as Class Full (for totally full events) and ‘Waitlist’ for events that are full but the waitlist is still available.

Thanks in advance for your attention. – Frank


Tony

  • Support Staff

July 30, 2021 at 6:50 am

Hi Frank,

That’s a little tricky, it is possible do although you’ll be increasing the queries a fair bit on the page.

I’d like to know if there is a way to distinguish between upcoming events where ticket sales have started (are open) and where ticket sales have not started yet

The EE_Event class has a tickets_on_sale() method which will return true if you currently have tickets on sale (based on dates), otherwise false.


if( $event->tickets_on_sale() ) {
    // The above method checks if the current date and time is between the sale starts and sale ends dates of tickets on the event.
    // If so the tickets are currently on sale, do something here.
} else {
    // Tickets not currently on sale, are any upcoming?
    $where = array(
        'Datetime.EVT_ID' => $event->ID(),
        'TKT_start_date'  => array('<', time()),
    );
    $upcoming_ticket = EEM_Ticket::instance()->get_one(array($where));
    if( $upcoming_ticket ) {
        // You have an upcoming ticket on the event 
        // (it doesn't matter if there is more than one, hence the use of get_one to reduce the query)
        // Do something for upcoming here.
    }
}

as well as events that are full with a wait list and events where even the wait list is full.

Full events will have a status of sold out, so you can check with is_sold_out() but you’ll then also need to check for waitlist spaces, something like this:


if( $event->is_sold_out() ) {
    // Event sold out but we don't know if we have waitlist spaces yet.
    $loader = EventEspresso\core\services\loaders\LoaderFactory::getLoader();
    $waitlistEventMeta = $loader->getNew('EventEspresso\WaitList\domain\services\event\WaitListEventMeta');
    $wait_list_reg_count = $waitlistEventMeta->getRegCount($event);
    $wait_list_spaces = $waitlistEventMeta->getWaitListSpaces($event);
    $promoted_reg_ids = $waitlistEventMeta->getPromotedRegIdsArrayCount($event);
    if ($wait_list_reg_count + $promoted_reg_ids < $wait_list_spaces) {
        // Waitlist spaces available.
    } else {
        // Event is sold out, no waitlist available.
    }
}

Note the above is untested but should help point you in the right direction for what you are trying to do.


infrasolutions

August 12, 2021 at 8:14 am

Thank you for the input Tony. Will try to work this out. Another question along the same lines.

Is it possible to remove the last column (registration) and make the Event name (or row) the clickable link/URL to the event?

Thanks in advance for your input. -Frank


Tony

  • Support Staff

August 13, 2021 at 3:49 am

Yes, the add-on allows you to load your over version of the template used from within your theme (preferably a child theme)

So copy the default template /eea-events-table-view-template/templates/espresso-events-table-template.template.php into your child theme and edit that version.

To remove the register column you remove line 50:

<th class="th-group" data-sort-ignore="true"></th>

and line 132 (131 after your’ve removed line 50):

<td class="td-group reg-col" nowrap="nowrap"><?php echo $live_button; ?></td>

Line 112 will have:

<td class="event_title event-<?php echo $post->ID; ?>"><?php echo $post->post_title; ?></td>

Swap the contents of the td to be the link to the event, something like:

<a href='<?php echo $event->get_permalink() ?>'><?php echo $event->name(); ?></a>

Then when you call the event table shortocde it will use that template. If you want to only do that on specific shortcode calls use a custom template name and then pass it to the shortcode, like so:

[ESPRESSO_EVENTS_TABLE_TEMPLATE template_file=espresso-events-table-template-no-reg-link.template.php]

(The above would work if the copy of the template you placed in your child theme was named espresso-events-table-template-no-reg-link.template.php)

Viewing 3 reply threads

The support post ‘Display the status of events in table view’ 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