Querying orders through WooCommerce rather than through posts

An order is a post today and the CRUD layer exists so that it does not have to be forever — code that queries wp_posts directly is code that breaks when the storage moves.

// tied to the storage
$q = new WP_Query( array(
    'post_type'   => 'shop_order',
    'post_status' => 'wc-processing',
    'meta_query'  => array( array( 'key' => '_customer_user', 'value' => $id ) ),
) );

// asks WooCommerce, which asks whatever the data store is
$orders = wc_get_orders( array(
    'status'   => 'processing',
    'customer' => $id,
    'limit'    => 50,
) );

It returns order objects rather than posts, so the calling code gets get_total() and get_items() instead of raw meta keys. The argument names are WooCommerce’s own and do not match WP_Query, which is the small friction that keeps people on the familiar version. The payoff is entirely in the future — and a custom order table has been discussed for long enough that betting against it is a poor trade.