Validate Restriction
apply_filters( 'vikappointments_before_validate_service_restriction', bool|null $valid, object $restr, string $checkin, bool $add )
Fires while checking whether the user is allowed to book a service according to the specified restriction criteria.
Description
This hook can be used to alter the validation of a booking restriction.
Parameters
- $valid
-
(bool|null) It is possible to return
FALSEto consider the restriction as applied and prevent the customer from booking the selected service. Otherwise it is possible to returnTRUEto consider the booking process valid without relying on the default validation process applied by the system. ReturnNULLto fallback to the default behavior.
$restr
-
(object) An object holding the restriction details.
- $checkin
-
(string) The UTC check-in date in military format (Y-m-d H:i:s).
- $add
-
(bool) True if the service has to be added, otherwise false if the service is already in the cart.
Example
/**
* Trigger event to allow the plugins to alter the validation of a booking restriction.
*
* It is possible to return FALSE to consider the restriction as applied and prevent the
* customer from booking the selected service. Otherwise it is possible to return TRUE
* to consider the booking process valid without relying on the default validation
* process applied by the system. Return null to fallback to the default behavior.
*
* @param bool|null $valid False to prevent the booking process, true to allow it.
* Otherwise null to preserve the default behavior.
* @param object $restr The restriction object.
* @param string $checkin The check-in in military format.
* @param bool $add True if the service has to be added, otherwise
* false if the service is already in the cart.
*/
add_filter('vikappointments_before_validate_service_restriction', function($valid, $restr, $checkin, $add) {
/**
* @todo apply some custom validations
*/
return $valid;
}, 10, 4); Changelog
| Version | Description |
|---|---|
| 1.2.16 | Introduced. |
Ultimo aggiornamento: 5 giorni fa
Utile?