• Resolved Bijdrager

    (@bijdrager)


    Hi Restaurant reservations, I’ve a question,

    How do I limit the times that can be booked by the following criteria?

    • People can book on the same day untill let’s say 16:00. Even when they make a booking 15:59. After this time they have to call when they want to make a reservation on that day.

    The last time to make a reservation is, let’s say 20:00. to make sure no one books online after 16:00, I have the rule that for late reservations they have to book 4hr before. However, this means people who want to make a reservation at 15:00 for 17:00 only get the options 19:00 or later.

    Could you please help me to fix this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support jaysupport

    (@jaysupport)

    Hi bij,

    There is currently no way to specify a time of day when bookings are no longer accepted. You can either set it relative, like you referenced (e.g. you can book up to 4 hours before the time of the reservation), or you can close same-day bookings.

    One alternative to achieve what you want would be to not use the late bookings setting and close your schedule at 16:00. Then put a message saying you can call for reservations after 16:00.

    Alternatively, we do have a filter that allows you to hook into the late bookings setting to create your own options. You can see an example of how to use it here: https://gist.github.com/fivestarplugins/b4e79247ac5f7974562752ac98dd4ba6

    Any values added to that array, however, are, by default, relative to the reservation time. So you would need to code your own function to alter this and then add that via our filter. If you know how to do that, or are working with a developer, this should be possible. However, as this is customization of the code to do something it is not designed to do, it would fall outside the scope of support and would not be something we could assist with.

    • This reply was modified 1 year, 2 months ago by jaysupport.

    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' ),
    						);
    					}
    
    				}
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Time limitation when booking’ is closed to new replies.