English (United Kingdom)

apply_filters_ref_array( 'vikrestaurants_load_restaurant_reservation_details', bool $status, mixed &$query, int $id, mixed $langtag, array $options )

Fires while creating the query used to load the details of a restaurant reservation.


Description

External plugins can attach to this hook in order to manipulate the query at runtime, useful to include some details that are not fetched by default.


Parameters

$status

(bool)  True on success, false otherwise. It is possible to manipulate this argument to alter the query used to fetch the reservation details.

&$query

(string|JDatabaseQuery)  Either a query string or a query builder instance.

$id

(int)  The ID of the reservation to load.

$langtag

(null/string)  An optional language tag for i18n support.

$options

(array)  An associative array containing a few loading options.


Example

The example below can be used to override the ordering of the query, by sorting the purchased products with their specified ordering.

/**
 * External plugins can attach to this hook in order to manipulate
 * the query at runtime, in example to alter the default ordering.
 *
 * @param   boolean  $status   True on success, false otherwise.
 * @param 	mixed    &$query   A query builder instance.
 * @param 	integer  $id       The ID of the reservation.
 * @param 	mixed    $langtag  The language tag. If null, the default one will be used.
 * @param 	array 	 $options  An array of options to be passed to the order instance.
 */
add_filter('vikrestaurants_load_restaurant_reservation_details', function($status, &$query, $id, $langtag, $options)
{
    $dbo = JFactory::getDbo();

    // let's load the product image too
    $query->select($dbo->qn('sp.image', 'product_image'));

    // join table holding the details of the product with the table of the purchased items
    $query->leftjoin($dbo->qn('#__vikrestaurants_section_product', 'sp') . ' ON ' . $dbo->qn('i.id_product') . ' = ' . $dbo->qn('sp.id'));

    // clear any other ordering
    $query->clear('order');
    // set our new ordering
    $query->order($dbo->qn('sp.ordering') . ' ASC');

    return true;
}, 10, 5);

Changelog

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