I have included that requested setting to my implementation.
It needs adaptions in the..
Settings.class.php to add the setting itself, e.g. “late-bookings-deadline’
“Latest possible reservation acceptance”
– “After this time is reached, reservations for today are no longer possible.”
$sap->add_setting(
'rtb-settings',
'rtb-global-settings',
'select',
array(
'id' => 'late-bookings-deadline',
'title' => __( 'Latest possible reservation acceptance', 'restaurant-reservations' ),
'description' => __( 'After this time is reached, reservations for today are no longer possible.', 'restaurant-reservations' ),
'blank_option' => false,
'options' => apply_filters( 'rtb_setting_deadline', array(
'' => __( 'No restriction', 'restaurant-reservations' ),
'05:00' => __( '05:00' ),
'05:30' => __( '05:30' ),
'06:00' => __( '06:00' ),
'06:30' => __( '06:30' ),
'07:00' => __( '07:00' ),
'07:30' => __( '07:30' ),
'08:00' => __( '08:00' ),
'08:30' => __( '08:30' ),
'09:00' => __( '09:00' ),
'09:30' => __( '09:30' ),
'10:00' => __( '10:00' ),
'10:30' => __( '10:30' ),
'11:00' => __( '11:00' ),
'11:30' => __( '11:30' ),
'12:00' => __( '12:00' ),
'12:30' => __( '12:30' ),
'13:00' => __( '13:00' ),
'13:30' => __( '13:30' ),
'14:00' => __( '14:00' ),
'14:30' => __( '14:30' ),
'15:00' => __( '15:00' ),
'15:30' => __( '15:30' ),
'16:00' => __( '16:00' ),
'16:30' => __( '16:30' ),
'17:00' => __( '17:00' ),
'17:30' => __( '17:30' ),
'18:00' => __( '18:00' ),
'18:30' => __( '18:30' ),
'19:00' => __( '19:00' ),
'19:30' => __( '19:30' ),
'20:00' => __( '20:00' ),
'20:30' => __( '20:30' ),
'21:00' => __( '21:00' ),
'21:30' => __( '21:30' ),
'22:00' => __( '22:00' ),
'22:30' => __( '22:30' ),
'23:00' => __( '23:00' ),
'23:30' => __( '23:30' ),
)
)
)
);
Ajax.class.php to compare setting with the current time -> blend out all times for current day if time is reached
above return $open_time;
// Time until which reservations are possible for the current day.
$late_bookings_deadline = ( is_admin() && current_user_can( 'manage_bookings' ) ) ? '' : $rtb_controller->settings->get_setting( 'late-bookings-deadline' );
if ( $late_bookings_deadline != '' ) {
// only if selected date is == today
if ( (new DateTime( 'now', wp_timezone() ) )->format( 'yyyyMMdd' ) == $selected_date->format( 'yyyyMMdd' ) ) {
// if current time 20:01 (example current time) > 20:00 (example setting), then blend out all times for current day
if ( (new DateTime( 'now', wp_timezone() ) )->format( 'H:i' ) > $late_bookings_deadline ) {
$time_calc = ( new DateTime( 'now', wp_timezone() ) )->format( 'U' ) + ( 2400 * 60 );
while ($time_calc > $open_time) {
$open_time = $open_time + $interval;
}
}
}
}
Booking.Class.php to let print an error “Sorry, last possible booking time for today already reached.”
$late_bookings_deadline = $rtb_controller->settings->get_setting( 'late-bookings-deadline' );
if ( empty( $late_bookings_deadline ) ) {
if ( $request->format( 'U' ) < $this->date_submission->format( 'U' ) ) {
$this->validation_errors[] = array(
'field' => 'time',
'error_msg' => 'late_bookings_deadline',
'message' => __( 'Sorry, last possible booking time for today already reached.', 'restaurant-reservations' ),
);
}
}