获取Woocommerce产品列表以及一周内订购的次数

时间:2016-05-04 19:27:04

标签: php wordpress woocommerce

我尝试了许多不同的方法,但似乎没有一种方法适合我。我试过像这样做一个WP_Query:

$query = new WP_Query([
    'post_type' => 'shop_order',
    'post_status' => 'publish',
    'posts_per_page' => '-1',
    'year' => date("Y"),
    'monthnum' => date("m"),
    'w' => date("W"),
]);

foreach ($query->posts as $order) {
  $product = $order->get_product_from_item($order->ID);

  echo $product->get_title();
  // Now I need the variation name and the amount of times the clientes orders this
}

基本上,我想得到一个项目的订单,显示当前一周订购的变化和次数。

这样的事情:

[product name] | [variation] | [total amount ordered by all customers]

有没有人知道我需要做什么才能实现这个目标?

0 个答案:

没有答案