Set minimum advanced notice for appointments

We would like to prevent customers from making appointments less than 24 hours in advance. Is there a way to do this? I couldn't find it in the settings.

  • Adam Czajczyk

    Hi Sara

    I hope you're well today and thank you for reaching out to us!

    Currently there's no such "limit" setting in the Appointments+ plugin but we have forwarded your question to our developers and they'll check if this could be achieved in any other way, for example with some additional code snippet.

    Please keep an eye on this ticket and we'll update you here as soon as we get to know more about possible options from them.

    Best regards,
    Adam

  • Konstantinos Xenos

    Hi Sara ,

    You could add this code snippet in your functions.php ( preferably your child themes ):

    add_filter( 'app_class_name', 'disable_twentyfourhour_appointments', 15, 3 );
    function disable_twentyfourhour_appointments( $class_name, $datetime_start, $datetime_end ) {
    	$time_dif = time() + 86400;
    
    	if ( $time_dif >= $datetime_start ) {
    		$class_name = 'notpossible app_past';
    	}
    
    	return $class_name;
    }

    What this will do is calculate the current time + 24 hours and show the appointments as not available when you're using the [app_schedule] & [app_monthly_schedule] shortcodes.

    I hope this helps!

    Regards,
    Konstantinos

    • Konstantinos Xenos

      Could you please update the code to this?

      The actual change is from time() to current_time( 'timestamp' ) . This should read the WP value instead. Sorry I missed this !

      add_filter( 'app_class_name', 'disable_twentyfourhour_appointments', 15, 3 );
      function disable_twentyfourhour_appointments( $class_name, $datetime_start, $datetime_end ) {
          $time_dif = current_time( 'timestamp' ) + 86400;
      
          if ( $time_dif >= $datetime_start ) {
              $class_name = 'notpossible app_past';
          }
      
          return $class_name;
      }

      Tell me if this works for you !

      Regards,
      Konstantinos

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.