Trying to modify existing woocommerce price slider for sorting on custom attribute value not by price, but stuck at modding sql query.

Here is a part of standard woocommerce price query to sql, but modified for getting one custom attribute ranges:

    $sql  = "SELECT min( FLOOR( post_meta.meta_value ) ) as min_maxcarry, max( CEILING( post_meta.meta_value ) ) as max_maxcarry FROM {$wpdb->posts} ";
    $sql .= " LEFT JOIN {$wpdb->postmeta} as post_meta ON {$wpdb->posts}.ID = post_meta.post_id " . $meta_query_sql['join'];
    $sql .= "   WHERE {$wpdb->posts}.post_type IN ('" . implode( "','", array_map( 'esc_sql', apply_filters( 'woocommerce_price_filter_post_type', array( 'product' ) ) ) ) . "')
                AND {$wpdb->posts}.post_status = 'publish'
                AND post_meta.meta_key IN ('" . implode( "','", array_map( 'esc_sql', apply_filters( 'woocommerce_price_filter_post_type', array( '_maxcarry' ) ) ) ) . "')
                AND post_meta.meta_value > '' ";
    $sql .= $meta_query_sql['where'];
    var_dump( $sql );
    return $wpdb->get_row( $sql );

Anyone can help with it or suggest another way to show this slider? thanks in advance

Read more here: Woocommerce custom attributes as a values for price range


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: