I'm trying to loop through all completed orders and print out their meta key and value, I can get the completed orders ID and bring back all the meta keys but not the values.
I'm new to PHP and woocommerce, so guess I'm missing something stupid!?
<?php
/**
* Template Name:test List
*/
wp_head();
Echo "testing";
$args = array(
'status' => 'completed',
//'meta_key' => 'arrival_date',
//'meta_value' => $today,
//'meta_compare' => '<=',
);
$orders = wc_get_orders( $args );
foreach ( $orders as $order ) {
$order_id = $order->get_id();
$order_meta = get_post_meta($order_id);
echo '<p>' . $order_id . '</p>';
foreach($order_meta as $key=>$val){
echo $key;
echo $val;
//echo is_array($val)?current($val):$val;
echo "<br>";
}
echo "<br>";
}
//echo '<pre>'; print_r($array); echo '</pre>';
wp_footer();