Filter
rpress_service_hours_instance
On this page
Filters the store hours engine object returned by rpress_service_hours().
Core creates an RPRESS_Service_Hours for the requested branch and passes it through this filter. You can return a subclass or a differently configured instance. It affects code that gets the engine through rpress_service_hours(), not code that constructs the class directly.
Available since RestroPress 3.5.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$engine | RPRESS_Service_Hours | New engine instance. |
$location_id | int|null | Branch term ID passed by the caller. Null means the customer's current branch; use $engine->get_location_id() for the resolved ID. |
Return value#
RPRESS_Service_Hours. Engine instance. It must be an RPRESS_Service_Hours or a subclass.
Example#
add_filter( 'rpress_service_hours_instance', 'my_service_hours_instance', 10, 2 );
function my_service_hours_instance( $engine, $location_id ) {
if ( 0 === $engine->get_location_id() ) {
return new RPRESS_Service_Hours( new DateTimeZone( 'Europe/London' ), null, $location_id );
}
return $engine;
}
Notes#
Changed in 3.5.1: a second argument, $location_id, was added, and rpress_service_hours() accepts it. The default instance is now built for that branch, or for the customer's current branch when it is null.
Source#
Applied in:
includes/features/slot-engine/functions.php(line 42), inrpress_service_hours()
See also#
Was this page helpful?
