Sort Products By Multiple Meta Keys
-
Hi All,
I’m trying to do a product sort using multiple meta keys. Particularly sorting by price and stock.
I see that class-wc-query.php handles the sorting, and the price case is using the meta key “_price”, but I also want to sort by meta key “_stock_status” to move all out of stock products to the end of the list. I know I can set out of stock products to not display, but the powers that be wish to leave them on the site for SEO purposes.
Here is the code handling the price sorting….
case ‘price’ :
$args[‘orderby’] = ‘meta_value_num’;
$args[‘order’] = $order == ‘DESC’ ? ‘DESC’ : ‘ASC’;
$args[‘meta_key’] = ‘_price’;
break;Can anyone guide me in the right direction as to how to handle this?
Thanks!
- The topic ‘Sort Products By Multiple Meta Keys’ is closed to new replies.