Automattic\WooCommerce\Admin\API\Reports\Coupons
DataStore::add_order_by_params()
Fills ORDER BY clause of SQL request based on user supplied parameters.
Method of the class: DataStore{}
No Hooks.
Return
null
. Nothing.
Usage
// protected - for code of main (parent) or child class $result = $this->add_order_by_params( $query_args, $from_arg, $id_cell );
- $query_args(array) (required)
- Parameters supplied by the user.
- $from_arg(string) (required)
- Target of the JOIN sql param.
- $id_cell(string) (required)
- ID cell identifier, like table_name.id_column_name.
DataStore::add_order_by_params() DataStore::add order by params code WC 7.3.0
protected function add_order_by_params( $query_args, $from_arg, $id_cell ) { global $wpdb; // Sanitize input: guarantee that the id cell in the join is quoted with backticks. $id_cell_segments = explode( '.', str_replace( '`', '', $id_cell ) ); $id_cell_identifier = '`' . implode( '`.`', $id_cell_segments ) . '`'; $lookup_table = self::get_db_table_name(); $order_by_clause = $this->add_order_by_clause( $query_args, $this ); $join = "JOIN {$wpdb->posts} AS _coupons ON {$id_cell_identifier} = _coupons.ID"; $this->add_orderby_order_clause( $query_args, $this ); if ( 'inner' === $from_arg ) { $this->subquery->clear_sql_clause( 'join' ); if ( false !== strpos( $order_by_clause, '_coupons' ) ) { $this->subquery->add_sql_clause( 'join', $join ); } } else { $this->clear_sql_clause( 'join' ); if ( false !== strpos( $order_by_clause, '_coupons' ) ) { $this->add_sql_clause( 'join', $join ); } } }