Woocommerce order empty items array

To fetch the order items you can use the method

get_items()

I am doing something similar to you and i am doing it like this

$order = wc_get_order($order_id);
$line_items = $order->get_items();

In WooCommerce 3.0, CRUD objects were added so all the data can be accessed using getters and set using setters. Line items are the same so when you have your line items you should loop them and access the data using getters.

For more information about the available getters and setters for these objects you can use this for reference https://docs.woocommerce.com/wp-content/images/wc-apidocs/class-WC_Order.html for the order object and for the product line items you can check https://docs.woocommerce.com/wc-apidocs/class-WC_Order_Item_Product.html

Hope this helps!

error code: 523