Unable to sort Orders on customer order page by meta value
-
Hi Guys,
I am trying to filter WC orders on customer order dashboard page using
woocommerce_my_account_my_orders_query
. and Order by date, title etc are working fine for me but when i try to filter orders by custom meta keys and values then it’s not returning me correct result.
add_filter( 'woocommerce_my_account_my_orders_query', 'af_filter_orders', 10, 1 );
function af_filter_orders( $orders ) { $orders = array( 'limit' => -1, 'offset' => null, 'page' => 1, 'meta_key' => 'custom_meta_key', //meta type is plain string and i need results alphabetically. 'orderby' => 'meta_value', //meta_value_num 'order' => 'DESC', //ASC 'customer' => get_current_user_id(), 'paginate' => true ); return $orders; }
I am on WC v2.6. have not tested on 3x yet. and i need it working with 2.6
- The topic ‘Unable to sort Orders on customer order page by meta value’ is closed to new replies.