I am trying to get all woocommerce orders and find info about the products in each order. I have seen many examples on here and elsewhere on the web and they all seem to say to do the same thing but it isn't working. I am on Wordpress 4.1.1 and Woocommerce 2.3.3 here is my code:
$filters = array(
'post_status' => 'any',
'post_type' => 'shop_order',
'posts_per_page' => 200,
'paged' => 1,
'orderby' =>'modified',
'order' => 'ASC'
);
$loop = new WP_Query( $filters );
while ( $loop->have_posts() ) {
$loop->the_post();
$order = new WC_Order($loop->post->ID);
foreach ($order->get_items() as $key => $lineItem) {
print_r($lineItem);
}
}
The problem is when I print_r($lineItem)
there are only three properties only two of which are ever populated. A typical print_r($lineItem)
looks like this:
Array (
[name] => Fouta Towel – Pearl Grey & White Stripe
[type] => line_item
[item_meta] =>
)
How do I get the rest of the information about this order item, e.g the product id, whether it is a single / variable product etc