Query Service Employees
apply_filters_ref_array( 'vikappointments_query_service_available_employees', bool $status, mixed &$query, mixed $search, string $date )
Fires before launching the query used to fetch the employees assigned to the selected service.
Description
Trigger hook to allow the plugins to manipulate the default query used to load the employees assigned to the selected service.
The query loads first the employees with the lowest count of overall reservations, so that we can have a correct balance.
It is possible to use this hook to improve this algorithm, in example by counting only the reservations of the last quarter.
NOTE: calling $search->isServiceAvailable()
will result in recursion.
Parameters
- $status
-
(bool) True on success, false otherwise.
- &$query
-
(mixed) Either a query builder or a SQL string.
- $search
-
(VAPAvailabilityImplementor) The instance used to check the availability.
- $date
-
(string) The check-in date (UTC).
Example
/**
* Trigger hook to allow the plugins to manipulate the default query used
* to load the employees assigned to the selected service. The query loads
* first the employees with the lowest count of overall reservations, so
* that we can have a correct balance.
*
* @param boolean $status True on success, false otherwise.
* @param mixed &$query Either a query builder or a string.
* @param mixed $search The availability search instance.
* @param string $date The check-in date (UTC).
*/
add_filter('vikappointments_query_service_available_employees', function($status, &$query, $search, $date)
{
/**
* @todo manipulate query here
*/
return $status;
}, 10, 4);
Changelog
Version | Description |
---|---|
1.2 | Introduced. |
Last Update: 2021-10-05
Helpful?