【发布时间】:2016-05-10 20:33:09
【问题描述】:
我正在寻找一种标准方法来获取用户在某个日期范围内或当月的订单总数。
在探索了 woocommerce 源代码之后,我得到的是,woo 正在使用类似这样的东西
$order_item_amounts = $this->get_order_report_data( array(
'data' => array(
'_line_total' => array(
'type' => 'order_item_meta',
'order_item_type' => 'line_item',
'function' => 'SUM',
'name' => 'order_item_amount'
),
'post_date' => array(
'type' => 'post_data',
'function' => '',
'name' => 'post_date'
),
'_product_id' => array(
'type' => 'order_item_meta',
'order_item_type' => 'line_item',
'function' => '',
'name' => 'product_id'
),
),
'where_meta' => array(
'relation' => 'OR',
array(
'type' => 'order_item_meta',
'meta_key' => array( '_product_id', '_variation_id' ),
'meta_value' => $this->product_ids,
'operator' => 'IN'
),
),
'group_by' => 'product_id, ' . $this->group_by_query,
'order_by' => 'post_date ASC',
'query_type' => 'get_results',
'filter_range' => true
) );
在 class-wc-report-sales-by-product.php 中
但如您所知,这是基于产品而非用户的。
从上面的代码,
$this->group_by_query 部分包含可在 woo 源中找到的日期条件。我的问题实际上是关于如何使用 woocommerce 的内置函数根据给定的日期范围生成订单列表。
谢谢
【问题讨论】:
标签: php wordpress plugins woocommerce