So I'm new to coding in Wordpress an woocommerce too!
I want to list all completed orders in the front end of a Wordpress site, order number and item ordered.
I have created a template file and I can get it run basic PHP such as echo and foreach, but I can't get my head around how to list completed orders!
however, the below code doesn't return any orders.
I found the commented out SQL statement which is more what I'm after i.e. return all orders that have a date of x in a text meta field. but I have no idea of how to include it in the template file!
<?php
/**
* Template Name: PPR List
*/
wp_head();
Echo "testing";
//"SELECT post_id FROM wp_postmeta WHERE meta_key = 'arrival_date' AND meta_value <= $today"
$all_orders = get_posts( array(
'numberposts' => $order_count,
'post_type' => wc_get_order_types( 'complete' ),
'post_status' => array_keys( wc_get_order_statuses() )
) );
echo '<pre>'; print_r($array); echo '</pre>';
wp_footer();