English (United Kingdom)

apply_filters_ref_array( 'vikappointments_build_all_orders_query', bool $status, mixed &$queryarray &$options )

Fires while loading the appointments to display.


Description

Trigger hook to manipulate at runtime the query used to load the appointments to display under the All Orders page in the front-end.

Third party plugins can extend the query by applying further conditions or selecting additional data.


Parameters

$status

(bool)  True on success, false otherwise.

&$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 appointments to display per page.

Example

The example below joins the appointments 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  boolean  $status    True on success, false otherwise.
 * @param  mixed    &$query    Either a query builder or a query string.
 * @param  array    &$options  An array of options.
 */
add_filter('vikappointments_build_all_orders_query', function($status, &$query, &$options)
{
    $dbo = JFactory::getDbo();

    // select some columns
    $query->select($dbo->qn(['tpt.column1', 'tpt.column2']));
    // join appointments to a third-party table
    $query->leftjoin($dbo->qn('#__myplugin_third_party_table', 'tpt') . ' ON ' . $dbo->qn('tpt.id_reservation') . ' = ' . $dbo->qn('r.id'));
    // avoid duplicates
    $query->group($dbo->qn('r.id'));

    return true;
}, 10, 3);

Changelog

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