Skip to content
Docs
Get RestroPress

Filter

rpress_service_hours_windows

Updated
On this page

Filters all the opening windows that start on a date, for example lunch and dinner shifts.

The list starts with the single window from get_window(), or is empty when that day is closed. Add, replace or remove windows, building each with $engine->make_window( $date, $open, $close ). Afterwards core drops entries without DateTimeImmutable open and close values and open_minutes and close_minutes, and sorts the rest by opening time. Open checks, next-opening lookups and slots use this list.

Available since RestroPress 3.5.1.

Parameters#

ParameterTypeDescription
$windowsarray[]Window arrays.
$datestringOpening date, Y-m-d.
$servicestringService type, may be empty.
$engineRPRESS_Service_HoursThe engine, for make_window() and get_location_id().

Return value#

array[]. Window arrays.

Example#

add_filter( 'rpress_service_hours_windows', 'my_split_shifts', 10, 4 );
function my_split_shifts( $windows, $date, $service, $engine ) {
	if ( empty( $windows ) ) {
		return $windows;
	}
	return array(
		$engine->make_window( $date, '11:30', '14:30' ),
		$engine->make_window( $date, '18:00', '22:00' ),
	);
}

Notes#

Results are cached per engine instance, service and date. This example replaces the hours of every open day.

Source#

Applied in:

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

See also#

Was this page helpful?