Tribe__Tickets_Plus__REST__V1__Endpoints__QR::is_tec_event_happening_now( int $event_id )
Check if an event is on date and time, in order to check-in QR codes.
Contents
Parameters
- $event_id
-
(int) (Required) The Event ID.
Return
(boolean) True if the Event is on date and time.
Source
File: src/Tribe/REST/V1/Endpoints/QR.php
public function is_tec_event_happening_now( $event_id ): bool {
// Get the event.
$event = tribe_get_event( $event_id );
// Bail if it's empty or if the ticket is from a page/post or any other CPT with tickets.
if ( empty( $event ) || $event->post_type !== Tribe__Events__Main::POSTTYPE ) {
return true;
}
// Get the time buffer option.
$time_buffer = (int) tribe_get_option( 'tickets-plus-qr-check-in-events-happening-now-time-buffer', 0 );
/**
* Filter the time buffer, in minutes.
* This buffer is for QR check-ins when it's set to only check-in when the event is on date and time.
*
* @since 5.6.2
*
* @param int $buffer The time buffer in minutes.
* @param int $event_id The event ID.
*/
$time_buffer = (int) apply_filters( 'tec_tickets_plus_qr_checkin_events_happening_now_buffer', $time_buffer, $event_id );
$time_buffer = ! empty( $time_buffer ) ? $time_buffer : 0;
$time_buffer_text = 'PT' . $time_buffer . 'M';
// Set up the dates for the event, with the corresponding timezone and buffer.
$now = Tribe__Date_Utils::build_date_object( 'now', $event->timezone );
$start = $event->dates->start->sub( new DateInterval( $time_buffer_text ) );
$end = $event->dates->end->add( new DateInterval( $time_buffer_text ) );
// Return if the event is happening now.
return $now >= $start && $now <= $end;
}
Changelog
| Version | Description |
|---|---|
| 5.6.2 | Introduced. |