Your cart is empty!
Build Query
public function onBuildSubscriptionOrdersQuery(mixed &$query, array &$options) : void
Fires while loading the subscription orders to display.
Description
Trigger hook to manipulate at runtime the query used to load the items to display under the Subscriptions History page in the front-end.
Third party plugins can extend the query by applying further conditions or selecting additional data.
The Subscriptions History page can be accessed from the All Orders page, by clicking the Purchased Subscriptions button.
Parameters
- &$query
-
(mixed) Either a query builder object or a plain string.
- &$options
-
(array) An array of options.
start
- the query offset to handle the pagination;limit
- the maximum number of orders to display per page.
Return Value
None.
Example
The example below joins the orders table to a third-party table to access further data.
/**
* Trigger hook to manipulate the query at runtime. Third party plugins
* can extend the query by applying further conditions or selecting
* additional data.
*
* @param mixed &$query Either a query builder or a query string.
* @param array &$options An array of options.
*
* @return void
*/
public function onBuildSubscriptionOrdersQuery(&$query, &$options)
{
$dbo = JFactory::getDbo();
// select some columns
$query->select($dbo->qn(['tpt.column1', 'tpt.column2']));
// join orders to a third-party table
$query->leftjoin($dbo->qn('#__myplugin_third_party_table', 'tpt') . ' ON ' . $dbo->qn('tpt.id_order') . ' = ' . $dbo->qn('o.id'));
// avoid duplicates
$query->group($dbo->qn('o.id'));
}
Changelog
Version | Description |
---|---|
1.7 | Introduced. |
Last Update: 2021-10-11 10:07
Helpful?