Your cart is empty!
Preferred Stay Time
apply_filters( 'vikrestaurants_use_preferred_stay_time', int $stayTime, int $default, mixed $search )
Fires while calculating the stay time to use for restaurant reservations.
Description
This filter can be used to alter at runtime the preferred stay time to use while booking a table.
It is possible to fetch the booking details by using $search->get($key) method, where $key can assume all the following values:
- date (string) - The check-in date, displayed with the preferred format.
- hour (int) - The check-in hours (24h format).
- min (int) - The check-in minutes.
- people (int) - The selected number of participants.
- room (int|null) - The room ID, when explicitly selected.
Parameters
- $stayTime
-
(int|null) The preferred stay time to use.
- $default
-
(int) The current default value.
- $search
-
(VREAvailabilitySearch) The instance holding the booking details.
Example
The example below uses a different stay time depending on the check-in hour.
/**
* Trigger an event to allow third-party plugins to alter the stay time at runtime.
*
* @param int|null $stayTime The preferred stay time.
* @param int $default The current default value.
* @param VREAvailabilitySearch $search The instance holding the booking details.
*
*/
add_filter('vikrestaurants_use_preferred_stay_time', function($stayTime, $default, $search) {
if ($search->get('hour') < 17) {
// reduce the stay time in case we are at lunch
return 60;
}
// use default stay time
return $stayTime;
}, 10, 3); Changelog
| Version | Description |
|---|---|
| 1.5 | Introduced. |
Last Update: 1 week ago
Helpful?