I have a built-in filter in my WooCommerce for ordering my products by price. When I choose to order them by price ascending, the products without price comes all the way to the top. I want these products to be right at the bottom of the page. Any suggestions?
PS I've only managed to hide these products from the list with this code in my functions.php file:
add_filter( 'woocommerce_product_query_meta_query', 'shop_only_instock_products', 10, 2 );
function shop_only_instock_products( $meta_query, $query ) {
if( is_admin() ) return $meta_query;
$meta_query['relation'] = 'OR';
$meta_query[] = array(
'key' => '_price',
'value' => '',
'type' => 'numeric',
'compare' => '!='
);
$meta_query[] = array(
'key' => '_price',
'value' => 0,
'type' => 'numeric',
'compare' => '!='
);
return $meta_query;
}
UPDATE: 8 days later I am still struggling with this one. Any help will be appreciated!