public function onCheckRestaurantFoodOrdering( object $reservation, string &$error ) : bool

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

$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.

Return Value

Boolean. Use false to deny the food ordering.


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  mixed   $reservation  The restaurant reservation to check.
 * @param  string  &$error       It is possible to include here the
 *                                reason of the error.
 *
 * @param  bool    Use false to deny the food ordering.
 */
public function onCheckRestaurantFoodOrdering($reservation, &$error)
{
    if ($reservation->deposit == 0) {
        // prevent food ordering in case of no deposit
        $error = 'You must leave a deposit before ordering the dishes.';
        return false;
    }

    return true;
}

Changelog

Version Description
1.8 Introduced.
Last Update: 2023-12-29 14:15
Helpful?