gpb_availability_end
Description
Filter the end date for availability checks. This filter allows you to set an absolute maximum date for bookings. Any dates after this will be marked as unavailable in REST responses and rejected during booking validation. Return null to allow bookings indefinitely into the future (no restriction outside of Availability Windows).
Usage
Filter applied globally to all availability checks
add_filter( 'gpb_availability_end', 'my_custom_function' );Parameters
$end
CarbonImmutable|null
End date (null = no restriction).
$service
Service
Service object.
$resource_ids
int[]
Resource IDs being checked.
Examples
Limit bookings to 6 months in advance
Prevent bookings more than 6 months in the future.
add_filter( 'gpb_availability_end', function( $end, $service, $resource_ids ) {
return \Carbon\CarbonImmutable::today()->addMonths( 6 );
}, 10, 3 );Limit bookings to end of current year
Only allow bookings through December 31st of the current year.
add_filter( 'gpb_availability_end', function( $end, $service, $resource_ids ) {
return \Carbon\CarbonImmutable::today()->endOfYear();
}, 10, 3 );Different limits for different services
Apply service-specific booking windows.
add_filter( 'gpb_availability_end', function( $end, $service, $resource_ids ) {
// Vacation rentals: 1 year advance
if ( $service->get_id() === 123 ) {
return \Carbon\CarbonImmutable::today()->addYear();
}
// Haircuts: 2 months advance
if ( $service->get_id() === 456 ) {
return \Carbon\CarbonImmutable::today()->addMonths( 2 );
}
return $end;
}, 10, 3 );Since
1.0-alpha-4.2Hook added.