English (United Kingdom)

apply_filters_ref_array( 'vikrestaurants_setup_restaurant_reservation_details', bool $status, object &$reservation, array $list )

Fires while creating the restaurant reservation object according to the details fetched by the query.


Description

External plugins can use this event to manipulate the object holding the details of the reservation. Useful to inject all the additional data fetched with the manipulation of the query.


Parameters

$status

(bool)  True on success, false otherwise.

&$reservation

(object)  The object holding the details of the reservation.

$list

(array)  All the records loaded through the database query.


Example

The example below can be used to implement a formatted version of the check-in.

/**
 * External plugins can use this event to manipulate the object holding
 * the details of the reservation. Useful to inject all the additional
 * data fetched with the manipulation of the query.
 *
 * @param   boolean  $status        True on success, false otherwise.
 * @param   mixed    &$reservation  The reservation details object.
 * @param   array    $list          The query resulting array.
 */
add_filter('vikrestaurants_setup_restaurant_reservation_details', function($status, &$reservation, $list)
{
    // fetch restaurant reservation menu items
    foreach ($list as $row)
    {
        if ($row->item_id && isset($reservation->items[$row->item_id]))
        {
            // assign the image fetched with the query manipulation
            $reservation->items[$row->item_id]->image = $row->product_image;
        }
    }

    // recover date and time format from configuration
    $config = VREFactory::getConfig();

    $df = $config->get('dateformat');
    $tf = $config->get('timeformat');

    // format check-in date and time
    $reservation->checkinDateTime = date($df . ' ' . $tf, $reservation->checkin_ts);

    return true;
}, 10, 3);

Changelog

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