Skip to content
Docs
Get RestroPress

Filter

rpress_service_hours_window

Updated
On this page

Filters the store's primary opening window that starts on a date.

Applied by RPRESS_Service_Hours::get_window() to the window built from the weekly store hours, or null when the store is closed that day. A window is an array with open and close (DateTimeImmutable), open_minutes, close_minutes (minutes since midnight of the opening day, above 1440 when overnight) and until_midnight; build one with $engine->make_window( $date, $open, $close ). Return null to treat the day as closed. The result is the starting entry of the list that the open checks and slot generation use.

Available since RestroPress 3.5.

Parameters#

ParameterTypeDescription
$windowarray|nullWindow for the date, or null when closed.
$datestringOpening date, Y-m-d.
$servicestringService type, may be empty.
$engineRPRESS_Service_HoursThe engine resolving the window.

Return value#

array|null. Window array, or null when closed.

Example#

add_filter( 'rpress_service_hours_window', 'my_holiday_window', 10, 4 );
function my_holiday_window( $window, $date, $service, $engine ) {
	if ( '12-24' === substr( $date, 5 ) ) {
		return $engine->make_window( $date, '11:00', '15:00' );
	}
	return $window;
}

Notes#

Changed in 3.5.1: the engine is passed as a new fourth argument. The new make_window() method builds the window, and rpress_service_hours_windows can add more windows on top of this one. The result is cached per engine instance, service and date.

Source#

Applied in:

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

See also#

Was this page helpful?