I am trying to display all Order Items (with the Item Meta) for All completed orders from the WooCommerce plugin. I also want to limit the display to 10 order items only. I have
Something like this should limit the amount of items displayed to 10:
'shop_order',
'post_status' => 'publish',
'posts_per_page' => 10,
'tax_query' => array(
array(
'taxonomy' => 'shop_order_status',
'field' => 'slug',
'terms' => array('completed')
)
)
);
$orders=get_posts($args);
$i=0;
foreach($orders as $o):
if($i>10){
break;
}
$order_id = $o->ID;
$order = new WC_Order($order_id);
foreach( $order->get_items() as $item ):
if($i>10){
break;
}
$i++;
$date = $item['Booking Date'];
$time = $item['Booking Time'];
$fname = $item['First Name - First Name'];
$church = $item['Church Information - Church Name'];
$city = $item['Church Information - City'];
$state = $item['Church Information - State'];
?>
If I understand what you're looking for correctly that should do the trick.