0

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

Tomasz Jakub Rup
  • 10,502
  • 7
  • 48
  • 49

2 Answers2

0

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;
}
Morteza Barati
  • 329
  • 3
  • 11
0

I think you are looking something like this https://wordpress.stackexchange.com/questions/287483/sorting-products-by-price-regular-sale-price

Even you can get idea from that Show Out of stock products at the end in Woocommerce

Note: WooCommerce has extension for that https://woocommerce.com/document/sale-product-first-for-woocommerce/

Biplob Ahmed
  • 106
  • 4