Order Query Generator
Query orders the HPOS-safe way — wc_get_orders() instead of a raw WP_Query on shop_order, which breaks the moment High-Performance Order Storage is on.
Status
2 statuses
Meta clauses
none
No meta clauses.
Shape of the result
A foreach loop over the results, ready to print.
// Generated with WP CodeKit — powered by GrowQuest (https://growquest.io). $args = array( 'status' => array( 'wc-processing', 'wc-completed' ), 'limit' => 20, 'orderby' => 'date', ); $orders = wc_get_orders( $args ); foreach ( $orders as $order ) { printf( '<li>#%1$s — %2$s — %3$s</li>', esc_html( $order->get_order_number() ), esc_html( wc_get_order_status_name( $order->get_status() ) ), wp_kses_post( wc_price( $order->get_total() ) ) ); }