Sort products by Sale price and stock status

Try this. I followed the WP_Query docs to build this. $args = [ ‘meta_query’ => [ ‘relation’ => ‘AND’, [ ‘_stock_status’ => [ ‘key’ => ‘_stock_status’, ‘compare’ => ‘EXISTS’, ], ‘_sale_price’ => [ ‘key’ => ‘_sale_price’, ‘compare’ => ‘EXISTS’, ], ‘_price’ => [ ‘key’ => ‘_price’, ‘compare’ => ‘EXISTS’, ] ] ], ‘orderby’ => [ … Read more

Woocommerce – Change order of products in Confirmed Order

Using a clean wordpress install, woocommerce and storefront theme, I came up with this code. It sorts regular products and variable products only. Only sorts in admin panel. Sorts by weight from hgih to low (you can see the commented section, you can uncomment the relevant option to you). The code goes into functions.php add_filter(‘woocommerce_order_get_items’, … Read more