我正在尝试编写一个函数来检索使用指定优惠券代码且在指定日期范围内的WooCommerce订单列表,然后将应用于这些订单的总折扣加起来.
经过一番谷歌搜索,我觉得我应该使用类似的东西
$customer_orders = get_posts( array(
'numberposts' => -1,
'meta_key' => ???,
'meta_value' => $CouponToSearchFor,
'post_type' => wc_get_order_types(),
'post_status' => array_keys( wc_get_order_statuses() ),
) );
Run Code Online (Sandbox Code Playgroud)
我试过了:
'meta_key' => 'coupon'
'meta_key' => 'shop_coupon'
'meta_key' => '_coupon'
Run Code Online (Sandbox Code Playgroud)
但这些都不起作用.我怎样才能找出哪些meta_key/ meta_value条款会给我我需要的东西?
另外我认为meta_query可以用来执行日期过滤作为此get_posts()查询的一部分,这是正确的吗?