English (United Kingdom)
Knowledge Base  >  Vik Restaurants  >  Hooks  >  Reservation  >  Validate Search

add_action( 'vikrestaurants_validate_reservation_search_query', array $data, mixed $specialDay )

Fires while validating the table booking request.


Description

Third party plugins can use this hook to perform an extended validation on the table booking search query.
It is possible to throw an exception to safely abort the booking process and present the error message to the guest.

Parameters

$data

(array)  The search query

  • date - the check-in date, formatted according to the configuration of the plugin;
  • hourmin - the check-in time, always in 24H format;
  • people - the number of participants;
  • table - the table that will be assigned to the reservation.
$specialDay

(VRESpecialDay)  The special day instance, if available.


Example

/**
 * Third party plugins can use this hook to perform an extended validation on the seach query.
 * It is possible to throw an exception to abort the booking process.
 * 
 * @param  array  $data        The search query (date, hour, min, people).
 * @param  mixed  $specialDay  The special day instance, if available.
 * 
 * @throws Exception
 */
add_action('vikrestaurants_validate_reservation_search_query', function($data, $specialDay) {
    /**
     * @todo perform extra checks here...
     */

    throw new Exception('Manually aborted by a custom script.');
}, 10, 2);

Changelog

Version Description
1.5 Introduced.
Last Update: 1 week ago
Helpful?