English (United Kingdom)
Knowledge Base  >  Vik Restaurants  >  Hooks  >  Take-Away  >  Prepare Times

apply_filters_ref_array( 'vikrestaurants_prepare_take_away_times', bool $status, array &$times, mixed $search )

Fires after calculating the times availability.


Description

Plugins can use this hook to manipulate the available timeslots at runtime, in order to enhance the default restrictions and the functionalities.

NOTE: the timeslots can be enabled/disabled by toggling the related disable property.


Parameters

$status

(bool)  True on success, false otherwise.

&$times

(array)  An array of working shifts and the releated timeslots.

$search

(VREAvailabilityTakeaway)  The instance used to calculate the availability of the times.


Example

The example explains how to manipulate the timeslots.

/**
 * Plugins can use this hook to manipulate the available timeslots
 * at runtime, in order to enhance the default restrictions and the
 * functionalities.
 *
 * @param  bool   $status  True on success, false otherwise.
 * @param  array  &$times  An array of working shifts and the releated timeslots.
 * @param  self   $search  The availability search instance.
 */
add_filter('vikrestaurants_prepare_take_away_times', function($status, &$times, $search)
{
    foreach ($times as &$shift)
    {
        foreach ($shift as &$slot)
        {
            $disable = true;
            /**
             * @todo fetch time slot status
             */

            // assign new status
            $slot->disable = $disable;
        }
    }

    return $status;
}, 10, 3);

Changelog

Version Description
1.2 Introduced.
Last Update: 2021-01-26
Helpful?
This site uses cookies. By continuing to browse you accept their use. Further information