Home > Blockchain >  I want to display regular_price products after sale_price products
I want to display regular_price products after sale_price products

Time:06-01

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

CodePudding user response:

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;
}

CodePudding user response:

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/

  • Related