WC_Query::order_by_rating_post_clauses PHP Method

order_by_rating_post_clauses() public method

Order by rating post clauses.
Deprecation: 2.7.0
public order_by_rating_post_clauses ( array $args ) : array
$args array
return array
    public function order_by_rating_post_clauses($args)
    {
        global $wpdb;
        wc_deprecated_function('order_by_rating_post_clauses', '2.7');
        $args['fields'] .= ", AVG( {$wpdb->commentmeta}.meta_value ) as average_rating ";
        $args['where'] .= " AND ( {$wpdb->commentmeta}.meta_key = 'rating' OR {$wpdb->commentmeta}.meta_key IS null ) ";
        $args['join'] .= "\n\t\t\tLEFT OUTER JOIN {$wpdb->comments} ON({$wpdb->posts}.ID = {$wpdb->comments}.comment_post_ID)\n\t\t\tLEFT JOIN {$wpdb->commentmeta} ON({$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id)\n\t\t";
        $args['orderby'] = "average_rating DESC, {$wpdb->posts}.post_date DESC";
        $args['groupby'] = "{$wpdb->posts}.ID";
        return $args;
    }