Italian (Italy)
Knowledge Base  >  Vik Restaurants  >  Hooks  >  Cibo per Ristoranti  >  Check Food Ordering

apply_filters_ref_array( 'vikrestaurants_check_restaurant_food_ordering', bool $allow, object $reservation, string &$error )

Fires while checking whether the user is allowed to order the food online.


Description

This filter can be used to apply additional conditions to the food ordering restrictions. Applies only for restaurant reservations.

When this hook is triggered, the system already validated the standard conditions and the ordering of the food has been approved for the usage.

In case of allowed ordering, the button called "Order Dishes" placed within the reservation summary will be no more DISABLED. In case the button is not visible, the Allow Courses Ordering setting might be turned off.


Parameters

$allow

(bool)  Use false to deny the food ordering.

$reservation

(VREOrderRestaurant)  An object containing the details of the reservation that is going to be cancelled.

&$error

(string)  It is possible to include here the reason of the failure.


Example

The example below prevents the food ordering for those customers that didn't leave a deposit online. In example, customers that selected the "Pay upon arrival" method of payment.

/**
 * This filter can be used to apply additional conditions to the 
 * food ordering restrictions. When this hook is triggered, the
 * system already validated the standard conditions and the
 * food ordering has been approved for the usage.
 *
 * @param  boolean  $allow        Use false to deny the food ordering.
 * @param  mixed    $reservation  The restaurant reservation to check.
 * @param  string   &$error       It is possible to include here the
 *                                reason of the error.
 */
add_filter('vikrestaurants_check_restaurant_food_ordering', function($allow, $reservation, &$error)
{
    if ($reservation->deposit == 0)
    {
        // prevent food ordering in case of no deposit
        $error = 'You must leave a deposit before ordering the dishes.';

        $allow = false;
    }

    return $allow;
}, 10, 3);

Changelog

Version Description
1.0 Introduced.
Ultimo aggiornamento: 2021-01-25
Utile?