Is there another method to return meta values for custom attributes that doesn't return a protected array
foreach ($order->get_items() as $item_key => $item_values) {
$item_id = $item_values->get_id();
$item_meta_data = $item_values->get_meta_data();
var_dump($item_meta_data);
}
It outputs:
object(WC_Meta_Data)#3433 (2) {
["current_data":protected]=>
array(3) {
["id"]=>
int(4690)
["key"]=>
string(14) "pa_second-half"
["value"]=>
string(11) "nutty-butty"
}
I've also tried this
$item_meta_data = $item_values->get_data();
$item_meta_data['key']
Which returns NULL.
Updated
To get order items meta data in an unprotected array you can use
WC_Order_Item
methodget_formatted_meta_data()
instead.So in the order items foreach loop:
You will get an unprotected array of accessible objects with like:
Related thread: Get Order items and WC_Order_Item_Product in Woocommerce 3