Sorting by high to low price is not working

Viewed 403

I have WooCommerce, installed at WP and some products, which have variations with prices. Each variation have field Regular price, and I need to sort by this price in the catalog. Sort by low to high is working well, but high to low is not working properly. It saved in database table wp_options as I found, not in wp_postmeta. В базе в таблице wp_options как я понял это хранится, а не в wp_postmeta. There is such JSON:

{"version":"1586002626","f9e544f77b7eac7add281ef28ca5559f":{"price":{"267":"20.00","269":"100.00"},"regular_price":{"267":"20.00","269":"100.00"},"sale_price":{"267":"20.00","269":"100.00"}},"98f9c03adb427b329f828827eb33e0bf":{"price":{"267":"20.00","269":"100.00"},"regular_price":{"267":"20.00","269":"100.00"},"sale_price":{"267":"20.00","269":"100.00"}}}

In functions.php I tried to do many things, now there is such code, but it's not sorting by ?orderby=price-desc.

add_filter( 'woocommerce_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args' );
function custom_woocommerce_get_catalog_ordering_args( $args ) {
    $args['orderby'] = '_transient_wc_var_prices';
    $args['order'] = 'desc';
    return $args;
}

Is there any ways to fix that?

0 Answers
Related