Different appointments lower limit (hours) for each service

Dear support-team

We just bought the Appointments+ Plugin. And now we need to set different times for the "appointments lower limit (hours)"-field for different services. An example:
Service 1: 48 hours blocking time for the user in the calendar
Service 2: 336 hours blocking time for the user in the calendar
Service 3: 240 hours blocking time for the user in the calendar

Is there a possiblity to set this? Or do you have an idea how we can adjust this in the source-code of the plugin?

Thank you very much for your help!

Best regards from switzerland

WEBSAMURAI AG
Samuel Bammert
samuel.bammert@websamurai.ch

  • Vaughan

    Hi @Websamurai,

    Hope you're well?

    This isn't possible out of the box, but you might be able to use a custom filter.

    I haven't tested this, but hopefully should work.

    add_filter( 'app_class_name', 'apps_custom_lower_limit', 99, 3);
    function apps_custom_lower_limit($class_name, $ccs, $cce) {
        global $appointments;
    
        $service = $appointments->get_service($appointments->service);
    
      	$class_name = '';
    	// Mark now
    	if ( $appointments->local_time > $ccs && $appointments->local_time < $cce ) {
    		$class_name = 'notpossible now';
        } elseif ( $appointments->local_time > $ccs ) {
    		$class_name = 'notpossible app_past';
        } elseif ( isset( $service ) ) {
            if (($appointments->local_time + 48 * 3600) > $cce) {
                $class_name = 'notpossible app_blocked';
            } elseif (($appointments->local_time + 336 * 3600) > $cce) {
                $class_name = 'notpossible app_blocked';
            } elseif (($appointments->local_time + 240 * 3600) > $cce) {
                $class_name = 'notpossible app_blocked';
            }
        } elseif ( $appointments->is_break( $ccs, $cce ) ) {
    				$class_name = 'notpossible app_break';
        } elseif ( $is_busy ) {
    				$class_name = 'busy';
        } elseif ( !$appointments->is_service_possible( $ccs, $cce, $capacity ) ) {
    				$class_name = 'notpossible service_notpossible';
        } else {
    		$class_name = 'free';
    		// We found at least one timetable cell to be free
    		$appointments->is_a_timetable_cell_free = true;
    	}
    
        return $class_name;
    }

    Add the above to your theme functions.php

    Hope this helps

    • Vaughan

      Hi Antonio,

      If you're just wanting the above code functionto work on a specific blog only, you can use the wp function get_current_blog_id()

      So, we simply change the code and add a check for blog_id to it.

      <?php
      add_filter( 'app_class_name', 'apps_custom_lower_limit', 99, 3);
      function apps_custom_lower_limit($class_name, $ccs, $cce) {
          $allowed_blogs = array(1,2,3);
          if(!in_array(get_current_blog_id(), $allowed_blogs)) return $class_name;
      
          global $appointments;
      
          $service = $appointments->get_service($appointments->service);
      
        	$class_name = '';
      	// Mark now
      	if ( $appointments->local_time > $ccs && $appointments->local_time < $cce ) {
      		$class_name = 'notpossible now';
          } elseif ( $appointments->local_time > $ccs ) {
      		$class_name = 'notpossible app_past';
          } elseif ( isset( $service ) ) {
              if (($appointments->local_time + 48 * 3600) > $cce) {
                  $class_name = 'notpossible app_blocked';
              } elseif (($appointments->local_time + 336 * 3600) > $cce) {
                  $class_name = 'notpossible app_blocked';
              } elseif (($appointments->local_time + 240 * 3600) > $cce) {
                  $class_name = 'notpossible app_blocked';
              }
          } elseif ( $appointments->is_break( $ccs, $cce ) ) {
      				$class_name = 'notpossible app_break';
          } elseif ( $is_busy ) {
      				$class_name = 'busy';
          } elseif ( !$appointments->is_service_possible( $ccs, $cce, $capacity ) ) {
      				$class_name = 'notpossible service_notpossible';
          } else {
      		$class_name = 'free';
      		// We found at least one timetable cell to be free
      		$appointments->is_a_timetable_cell_free = true;
      	}
      
          return $class_name;
      }

      So with the above, you can see an array called $allowed_blogs.

      Simply add the blog_id to that array, seperated by a comma, in the code above, i added 1,2,3, this means that the function will be applied to blog ids 1, 2 & 3 only.

      You will need to add the above code to a mu-plugin, todo this;

      1. create a file called wpmudev_apps_lower_limit.php

      2. Add the above code to this file (making sure that <?php is on the very first line with no whitespace in front of it.

      3. Copy this file to /wp-content/mu-plugins

      Hope this helps

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.