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
    • Support Gorilla

    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
    • Rubber Duck Debugger

    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

  • Sara
    • Flash Drive

    Hi Konstantinos,

    Thank you for putting this fix together! I've implemented it and it is working. Only issue is that it is calculating 24 hours from UTC time instead of the time set in WordPress (UTC -5). Please see screenshot.

    Is it possible to adjust to pull from the UTC time set in WordPress?

    Regards,

    Sara

    • Konstantinos Xenos
      • Rubber Duck Debugger

      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

  • Predrag Dubajic
    • Support

    Hi Sara,

    I wanted to jump in here because it seems to me that there was some misunderstanding at the start about the option itself.

    A+ does actually have limits option that I believe is what you're looking for, you can find lower and upper booking limits under Appointments > Settings panel:

    Best regards,

    Predrag

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.