【发布时间】:2017-03-07 07:59:22
【问题描述】:
我想在插件函数中获取当前用户下的所有订单。
我正在使用这个:
function get_all_orders(){
$customer_orders = get_posts( apply_filters( 'woocommerce_my_account_my_orders_query', array(
'numberposts' => $order_count,
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id(),
'post_type' => wc_get_order_types( 'view-orders' ),
'post_status' => array_keys( wc_get_order_statuses() )
) ) );
return $customer_orders;
}
这在主题中运行良好,但在自定义插件中它不会返回任何内容。 难道我做错了什么?我应该先调用一些 WooCommerce 课程吗?
【问题讨论】:
-
我已经在一个插件中测试了你的代码,激活它,并且在前端没有任何需求就可以完美地工作。你的问题出在别的地方……
标签: php wordpress woocommerce