I want to get all order amounts and the payment date of orders made by current user inside a plugin.
I'm using this code, it currently prints order values: Like this 150001000 where 1st order is 0(starting from right) and 2nd is 100 and third is 15000. What I am trying to accomplish is putting orders amounts and dates in variables.
$customer = wp_get_current_user();
// Get all customer orders
$customer_orders = get_posts( array(
'numberposts' => -1,
'meta_key' => '_customer_user',
'orderby' => 'date',
'order' => 'DESC',
'meta_value' => get_current_user_id(),
'post_type' => wc_get_order_types(),
'post_status' => array_keys( wc_get_order_statuses() ), 'post_status'
=> array( 'wc-processing'),
) );
//echo count( $customer_orders );
foreach ( $customer_orders as $customer_order ) {
$orderq = wc_get_order( $customer_order );
$totalq = $orderq->get_total();
echo $totalq;
}