Automattic\WooCommerce\Blocks\BlockTypes
AbstractProductGrid::set_ordering_query_args()
Parse query args.
Method of the class: AbstractProductGrid{}
No Hooks.
Return
null
. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->set_ordering_query_args( $query_args );
- $query_args(array) (required) (passed by reference — &)
- Query args.
AbstractProductGrid::set_ordering_query_args() AbstractProductGrid::set ordering query args code WC 9.4.2
protected function set_ordering_query_args( &$query_args ) { if ( isset( $this->attributes['orderby'] ) ) { if ( 'price_desc' === $this->attributes['orderby'] ) { $query_args['orderby'] = 'price'; $query_args['order'] = 'DESC'; } elseif ( 'price_asc' === $this->attributes['orderby'] ) { $query_args['orderby'] = 'price'; $query_args['order'] = 'ASC'; } elseif ( 'date' === $this->attributes['orderby'] ) { $query_args['orderby'] = 'date'; $query_args['order'] = 'DESC'; } else { $query_args['orderby'] = $this->attributes['orderby']; } } $query_args = array_merge( $query_args, WC()->query->get_catalog_ordering_args( $query_args['orderby'], $query_args['order'] ) ); }