Italian (Italy)
Knowledge Base  >  Vik Restaurants  >  Hooks  >  Cancellazione  >  Controllo Ordini

apply_filters( 'vikrestaurants_check_order_cancellation', bool $allow, object $order )

Fires while checking whether the cancellation is allowed for the specified order.


Description

This filter can be used to apply additional conditions to the cancellation restrictions. Applies only for take-away orders.

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

In case of allowed cancellation, the page containing the details of the purchase will report a button to cancel the order.


Parameters

$allow

(bool)  Use false to deny the cancellation.

$order

(VREOrderTakeaway)  An object containing the details of the order that is going to be cancelled.


Example

The example below prevents the cancellation for those customers that didn't pay the order online. In example, customers that selected the "Pay upon arrival" method of payment.

/**
 * This filter can be used to apply additional conditions to the 
 * cancellation restrictions. When this hook is triggered, the
 * system already validated the standard conditions and the
 * cancellation has been approved for the usage.
 *
 * @param  boolean  $allow  Use false to deny the cancellation.
 * @param  mixed    $order  The take-away order to check.
 */
add_filter('vikrestaurants_check_order_cancellation', function($allow, $order)
{
    // prevent cancellation in case the order was not paid online
    return $order->tot_paid > 0 ? true : false;
}, 10, 2);

Changelog

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