Php woocommerce获取订单报告数据以显示订单项目id
我想通过获取订单报告数据来显示订单项目id 我可以使用数组显示产品id和订单id:Php woocommerce获取订单报告数据以显示订单项目id,php,wordpress,woocommerce,Php,Wordpress,Woocommerce,我想通过获取订单报告数据来显示订单项目id 我可以使用数组显示产品id和订单id: array( '_product_id' => array( 'type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => '', 'name' => 'product_id' ), 'order_id'
array(
'_product_id' => array(
'type' => 'order_item_meta',
'order_item_type' => 'line_item',
'function' => '',
'name' => 'product_id'
),
'order_id' => array(
'type' => 'order_item',
'order_item_type' => 'line_item',
'function' => '',
'name' => 'order_id'
)
)
但不适用于订单项目id
有什么建议吗?深度thx。您可以使用此代码实现所需的结果
<?php
$sold_products = $wc_report->get_order_report_data(array(
'data' => array(
'_product_id' => array(
'type' => 'order_item_meta',
'order_item_type' => 'line_item',
'function' => '',
'name' => 'product_id'
),
'_qty' => array(
'type' => 'order_item_meta',
'order_item_type' => 'line_item',
'function' => 'SUM',
'name' => 'quantity'
),
'_line_subtotal' => array(
'type' => 'order_item_meta',
'order_item_type' => 'line_item',
'function' => 'SUM',
'name' => 'gross'
),
'_line_total' => array(
'type' => 'order_item_meta',
'order_item_type' => 'line_item',
'function' => 'SUM',
'name' => 'gross_after_discount'
)
),
'query_type' => 'get_results',
'group_by' => 'product_id',
'where_meta' => '',
'order_by' => 'quantity DESC',
'order_types' => wc_get_order_types('order_count'),
'filter_range' => TRUE,
'order_status' => array('completed'),
));