我正在创建一个插件,我想在woocommerce中获取订单数据,我做了很多尝试,但没有任何效果,请帮助我获取我想要的数据。
我想获取store_name,但我不能这样做,请帮忙。任何解决方案表示赞赏!
这是数组输出
Array
(
[id] => 107
[order_id] => 536
[name] => quantity test
[product_id] => 535
[variation_id] => 0
[quantity] => 5
[tax_class] =>
[subtotal] => 10
[subtotal_tax] => 0
[total] => 10
[total_tax] => 0
[taxes] => Array
(
[total] => Array
(
)
[subtotal] => Array
(
)
)
[meta_data] => Array
(
[0] => WC_Meta_Data Object
(
[current_data:protected] => Array
(
[id] => 1146
[key] => store_info_meta
[value] => Array
(
[store_code] => 01b3
[store_name] => 24
)
)
)
)
)
)
这是我的代码
$args = array(
'return' => 'ids',
'limit' => -1
);
$orders = wc_get_orders($args);
foreach ($orders as $key => $order_id) {
$order = new WC_Order($order_id);
$items = $order->get_items();
foreach ($items as $item) {
echo '<pre>';
print_r($item->get_data());
}
}