Ecommerce Shopify WordPress Discussion

Order WooCommerce "Orders" by multiple custom meta fields

I am trying to set a custom sort on the WooCommerce Orders page based on multiple meta keys, and am not having any luck. To be clear, custom__num_skus_total and _order_total are numeric, but custom__sku_most_freq is a string. This is the code I have so far, which the Orders page seems to disregard. None of my sorting is propagating add_action( 'parse_query', 'custom_set_sorting' ); function custom_set_sorting( $query ) { $meta_query = array( 'relation' => 'AND', 'num_skus_total' => array( 'key' => 'custom__num_skus_total', 'type' => 'numeric', 'compare' => 'EXISTS' ), 'sku_most_freq' => array( 'key' => 'custom__sku_most_freq', 'compare' => 'EXISTS' ), 'order_total' => array( 'key' => '_order_total', 'type' => 'numeric', 'compare' => 'EXISTS' ) ); $orderby = array( 'num_skus_total' => 'ASC', 'sku_most_freq' => 'ASC', 'order_total' => 'ASC' ); $query->set( 'meta_query', $meta_query ); $query->set( 'orderby', $orderby ); }
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.