English (United Kingdom)
Knowledge Base  >  Vik Restaurants  >  Hooks  >  Restaurant Food  >  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.
Last Update: 2021-01-25
Helpful?

This website uses cookies

This website uses cookies and similar technologies. Some of these technologies are necessary for the proper functioning of the website (Essential). Other technologies are used to evaluate user behavior (Analysis), to integrate external media or for advertising purposes. If you agree, these technologies are activated. For details, please refer to the privacy policy. From this same page you can also update/revoke your consent. If you do not give your consent, only cookies with essential functions will be activated.

We use technologies from the USA on our website. If you give your consent, you therefore consent at the same time to your data being transferred to the USA. We would like to point out that the USA does not have a level of data protection comparable to that of the EU and that any US company can be obliged by state authorities to hand over your data without you having any effective legal protection against this.