2020-09-28

Woocommerce problem write a custome order

Hi I have had a problem with arrays for a few days in Woocommerce orders.The problem is that I cannot enter the tables into one larger one.And then sending this board as json as presented.My question is how do I get those arrays I have out into one. I tried and I couldn't write them.

Code

function get_all_order_id()
{
    
         $args = array(
          'limit'           => -1,
          'return'          => 'ids',
          'date_completed'  => '2018-10-01...'.date('Y-m-d', strtotime(date("Y-m-d") . ' +2 day')).'',
          'status'          => 'completed'
        );
        $query = new WC_Order_Query( $args );
        $orders = $query->get_orders();
        $i = 0 ;
        foreach( $orders as $order_id ) 
        {
          get_order_details($order_id);
        }
}
function get_order_details($order_id)
{
    $order = wc_get_order( $order_id );
    $items = $order->get_items();
    $order_meta = get_post_meta($order_id);
    $c_order = [];
  
    
        foreach ( $items as $item_id => $item_data ) 
        {
          
            $c_order[] = [
            ...data

            ];   
            
            
        }
   finaly_array($c_order);
}
function finaly_array($data)
{
    $finaly = [];
    
        foreach ($data as $key ) 
        {   
            
            $finaly[$i] = [
                  
                ...data
                
            ];
          
        }
       
    wp_send_json($finaly);


}

Output array run this code

array(6) {
...
}
array(6) {
 ...
}

Final effect

array{
 [0]array(6) {
  ...
}
[1]array(6) {
  ...
}
[2]array(6) {
  ...
}
}


from Recent Questions - Stack Overflow https://ift.tt/3jfdR36
https://ift.tt/eA8V8J

No comments:

Post a Comment