WC_Shortcode_Products::order_by_rating_post_clauses()public staticWC 3.2.0

Order by rating.

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

Хуков нет.

Возвращает

Массив.

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

$result = WC_Shortcode_Products::order_by_rating_post_clauses( $args );
$args(массив) (обязательный)
Query args.

Список изменений

С версии 3.2.0 Введена.

Код WC_Shortcode_Products::order_by_rating_post_clauses() WC 8.7.0

public static function order_by_rating_post_clauses( $args ) {
	global $wpdb;

	$args['where']  .= " AND $wpdb->commentmeta.meta_key = 'rating' ";
	$args['join']   .= "LEFT JOIN $wpdb->comments ON($wpdb->posts.ID = $wpdb->comments.comment_post_ID) LEFT JOIN $wpdb->commentmeta ON($wpdb->comments.comment_ID = $wpdb->commentmeta.comment_id)";
	$args['orderby'] = "$wpdb->commentmeta.meta_value DESC";
	$args['groupby'] = "$wpdb->posts.ID";

	return $args;
}