Automattic\WooCommerce\Blocks\BlockTypes
AbstractProductGrid::set_ordering_query_args
Parse query args.
Метод класса: AbstractProductGrid{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->set_ordering_query_args( $query_args );
- $query_args(массив) (обязательный) (передается по ссылке — &)
- Query args.
Код AbstractProductGrid::set_ordering_query_args() AbstractProductGrid::set ordering query args WC 10.7.0
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'] )
);
}