Caricamento Dettagli
apply_filters_ref_array( 'vikrestaurants_load_takeaway_order_details', bool $status, mixed &$query, int $id, mixed $langtag, array $options )
Fires while creating the query used to load the details of a take-away order.
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.
- &$query
-
(string|JDatabaseQuery) Either a query string or a query builder instance.
- $id
-
(int) The ID of the order 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. Since the 1.2.1 version of the plugin, all the purchased products are sorted according to their custom ordering. Before this version the products were ordered according to their creation date (first purchase comes first). This example restores the behavior used before the 1.2.1 version.
/**
* 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 order.
* @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_takeaway_order_details', function($status, &$query, $id, $langtag, $options)
{
$dbo = JFactory::getDbo();
// let's load the image of the products too
$query->select($dbo->qn('p.img_path', 'item_image'));
// clear any other ordering
$query->clear('order');
// restore ordering by item ID
$query->order($dbo->qn('i.id') . ' ASC');
return true;
}, 10, 5);
Changelog
Version | Description |
---|---|
1.2.1 | Introduced. |