I want to sort product on category listing page. Want to display sale product first and remaning product after sale product. I have used woocommerce_get_catalog_ordering_args hook for sorting but not working.
My code looks like this
function catalog_ordering_args( $ args ) { if( !is_product_category() ){ return $ args; } $ args['orderby'] = 'meta_value_num'; $ args['order'] = 'ASC'; $ args['meta_key'] = '_sale_price'; return $ args; } add_filter( 'woocommerce_get_catalog_ordering_args', 'catalog_ordering_args', 20, 1 );
It should also work for variation products