Allowing multiple booking per slot

The custom code provided by the thread below, no longer works
https://premium.wpmudev.org/forums/topic/how-do-i-increase-capacity-for-each-time-slot-also-reports-for-service-providers#post-1310324

The code is supposed to allow multiple booking per slot, but still, only one slot can be booked.

  • Adam Czajczyk

    Hello Neil

    I hope you're well today and thank you for your question!

    The code that you were trying to add was originally provided by me in that other thread. I posted two version of that code there and the first one is actually taken directly from Appointments FAQ. (See "Appointments -> FAQ" -> "I want to accept more than one appointment application for each time slot").

    The code wouldn't work if there's a single service provider assigned to a service. However, I tested the code again in various ways and this time I couldn't also make it work so I think something's changed in a plugin's core since the code was provided.

    Our developers have been informed about this and are looking into it.

    A working solution, instead of the code, would be to create some additional user account on the site (a simple "subscriber" will do) and add them as service providers to the service, marking the "dummy" check box. If, for example, you want to get 10 bookings max capacity, 10 dummy service providers would work.

    As for the code, please keep an eye on this thread and we'll update it as soon as we get a feedback from our developers.

    Kind regards,
    Adam

  • Ivan

    Hi Neil !

    FIrst of all, I recommend you to use several "dummy" Service Provider because as that description says "Capacity field is for limiting the workforce, not for increasing it." and maybe you can face to some other bugs to use the following workaround.
    Where do you use that solution add one more line t the end of it
    add_filter( 'app-is_busy', '__return_false', 11 );
    Also, please, open {wprdpress_folder}/wp-content/plugins/appointments/includes/helpers.php file via FTP, find the apppointments_is_range_busy function there and replace these lines (approximately line 421)

    if ( $apps ) {
    	foreach ( $apps as $app ) {
    		//if ( $start >= strtotime( $app->start ) && $end <= strtotime( $app->end ) ) return true;
    		$app_properties = apply_filters( 'app-properties-for-calendar', array( 'start' => $app->start, 'end' => $app->end ), $app, $args );
    
    		if ( $period->contains( $app_properties['start'], $app_properties['end'], true ) ) {
    			return true;
    		}
    	}
    }
    
    // If we're here, no worker is set or (s)he's not busy by default. Let's go for quick filter trip.
    $is_busy = apply_filters( 'app-is_busy', false, $period );

    to these ones

    $is_busy = false;
    if ( $apps ) {
    	foreach ( $apps as $app ) {
    		//if ( $start >= strtotime( $app->start ) && $end <= strtotime( $app->end ) ) return true;
    		$app_properties = apply_filters( 'app-properties-for-calendar', array( 'start' => $app->start, 'end' => $app->end ), $app, $args );
    
    		if ( $period->contains( $app_properties['start'], $app_properties['end'], true ) ) {
    			$is_busy = true;
    		}
    	}
    }
    
    // If we're here, no worker is set or (s)he's not busy by default. Let's go for quick filter trip.
    $is_busy = apply_filters( 'app-is_busy', $is_busy, $period );

    I'll implement this change to the next version of the plugin.

    Best,
    Ivan.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.