Skip to content
Docs
Get RestroPress

Filter

rpress_service_hours_slots

Updated
On this page

Filters the order time slots the store hours engine generates for a date.

Applied at the end of RPRESS_Service_Hours::get_slots(), after slots from all windows on that calendar date (including after-midnight slots from the previous day) are built, past ones removed if requested, and sorted. Remove or add DateTimeImmutable values and return a zero-indexed list in time order. The engine also uses get_slots() to find available dates, the next available slot and the midnight rollover, so removing slots affects those too.

Available since RestroPress 3.5.

Parameters#

ParameterTypeDescription
$slotsDateTimeImmutable[]Slots in time order, in the site timezone.
$date_keystringCalendar date, Y-m-d.
$servicestringService type, may be empty.
$argsarrayRequest options hide_past and respect_horizon (both bool).
$engineRPRESS_Service_HoursThe engine generating the slots.

Return value#

DateTimeImmutable[]. Slot list.

Example#

add_filter( 'rpress_service_hours_slots', 'my_block_kitchen_break', 10, 5 );
function my_block_kitchen_break( $slots, $date_key, $service, $args, $engine ) {
	$kept = array();
	foreach ( $slots as $slot ) {
		if ( '15' !== $slot->format( 'H' ) ) {
			$kept[] = $slot;
		}
	}
	return $kept;
}

Notes#

Changed in 3.5.1: the engine is passed as a new fifth argument. The incoming slots can also come from several windows per day and follow the new last_order_buffer and lead_time settings. Not applied when the date is invalid, or outside the booking horizon while respect_horizon is true.

Source#

Applied in:

  • includes/features/slot-engine/class-rpress-service-hours.php (line 614), in RPRESS_Service_Hours::get_slots()

See also#

Was this page helpful?