skip to Main Content

I want to display regular_price product after sale_price product. For example product #5 is not sale_price, i want it to be after product #6. Product with sale_price will come before regular_price products.
enter image description here

2

Answers


  1. I’m not sure this code works properly, but this way you can display specialty or auction products at the top of the screen.

    add_filter('woocommerce_get_catalog_ordering_args', 'sort_by_sale_price', 9999);
    function sort_by_sale_price($args)
    {
        $args['orderby'] = 'meta_value';
        $args['order'] = 'ASC';
        $args['meta_key'] = '_sale_price';
        return $args;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search