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: 
Below you can find the code which will give you an array with orders value date and id 

```
 $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'),
    ));

    $Order_Array = []; //
    foreach ($customer_orders as $customer_order) {
        $orderq = wc_get_order($customer_order);
        $Order_Array[] = [
            "ID" => $orderq->get_id(),
            "Value" => $orderq->get_total(),
            "Date" => $orderq->get_date_created()->date_i18n('Y-m-d'),
        ];

    }

```

Basically what we did here is just storing the values you want in array so you can use them later somewhere in your script 

**Output**

```
Array
(
[0] => Array
    (
        [ID] => 136
        [Value] => 240.00
        [Date] => 2018-08-13
    )

[1] => Array
    (
        [ID] => 116
        [Value] => 97.99
        [Date] => 2018-08-10
    )

 )

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

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

```