I took another look at exposing WC Orders to queries this morning and the issue is much simpler than I had thought when travelling down that rabbit hole yesterday.
WC Orders are stored with custom post statuses.
A View will query posts with a post status of publish or private.
So you need to modify the query arguments for the View in question to change the post status. You can change it to 'any', as shown in the example below, or you can use a particular status relevant for orders (you should check the slug of the status in the database to confirm the name used if you want to do this).
/**
* Modify query for Orders for any post status
*/
function prefix_expose_orders( $view_args, $view_settings, $view_id ){
if ( 197 == $view_id ) { // Edit View ID
$view_args['post_status'] = 'any';
}
return $view_args;
}
add_filter( 'wpv_filter_query', 'prefix_expose_orders', 101, 3);
nice! great thinking.
but now i'm getting all user names from orders, and if i user the "wpv_woo_product_belongs_to_this_order" condition, i'm getting zero.
we're T_H_I_S close!
thanks!
ido