Question: 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;       
} 

```

Answer: 
I solved my need with that approach (`wc_get_orders` is recommended by the vendor for using):

```php
    public function get_sum_of_paid_orders( int $user_id ): int {

        $customer_orders = [];
        foreach ( wc_get_is_paid_statuses() as $paid_status ) {
            $customer_orders += wc_get_orders( [
                'type'        => 'shop_order',
                'limit'       => - 1,
                'customer_id' => $user_id,
                'status'      => $paid_status,
            ] );
        }

        $total = 0;
        foreach ( $customer_orders as $order ) {
            $total += $order->get_total();

            // your code is here
        }

        return $total;
    }

```
You can get the order date by using the code below

```
$order = new WC_Order($order_id);
$order_date = $order->order_date;

```