eventsmanager icon

Workaround fix: {waitlist_full} ... {/waitlist_full}

eventsmanager | PRO | 03/03/25 08:45:27 AM UTC | 0 ⭐ | 290 👁️ | Never ⏰ | []
text |

1 KB

|

None

|

0 👍

/

0 👎

<?php
 function my_em_event_output_show_condition($show, $condition, $full_match, $EM_Event){
	global $wpdb;
	switch ($condition) {
 		case 'waitlist_full' : // waitlist is enabled and full
			$reserved                = $wpdb->get_var('SELECT SUM(booking_spaces) FROM '.EM_BOOKINGS_TABLE.' WHERE event_id='. absint($EM_Event->event_id) .' AND booking_status=6 GROUP BY event_id');	
			$is_enabled              = get_option('dbem_waitlists');
			$is_fully_booked         = $reserved <= 0; 
			$is_waitlist_available   = $EM_Event->get_bookings()->get_available_spaces(); 
			$show = $is_enabled && $is_fully_booked && $is_waitlist_available;
			if( $condition === 'waitlist_closed' ) $show = !$show; // opposite of closed
			if( $condition === 'waitlist_full' ) $show = $is_enabled && $is_fully_booked && !$is_waitlist_available; // only waitlist should be unavailable here
			break;		
 	}
	return $show;
}
add_filter('em_event_output_show_condition', 'my_em_event_output_show_condition', 100, 4);

Comments