Automattic\WooCommerce\Blocks\BlockTypes

ProductQuery::get_custom_orderby_query()privateWC 1.0

Return query params to support custom sort values

Метод класса: ProductQuery{}

Хуков нет.

Возвращает

Массив.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->get_custom_orderby_query( $orderby );
$orderby(строка) (обязательный)
Sort order option.

Код ProductQuery::get_custom_orderby_query() WC 8.7.0

private function get_custom_orderby_query( $orderby ) {
	if ( ! in_array( $orderby, $this->custom_order_opts, true ) ) {
		return array( 'orderby' => $orderby );
	}

	$meta_keys = array(
		'popularity' => 'total_sales',
		'rating'     => '_wc_average_rating',
	);

	return array(
		'meta_key' => $meta_keys[ $orderby ],
		'orderby'  => 'meta_value_num',
	);
}