【发布时间】:2021-11-13 22:49:28
【问题描述】:
我想知道,如何查看所有订单:
- 用户元密钥:
friseur - 用户元值:
TestFriseur
这是我的代码:
// Users query
$user_ids = (array) get_users([
'role' => 'customer',
'number' => - 1,
'fields' => 'ID',
'meta_query' => [
'relation' => 'OR',
[
'key' => 'TestFriseur',
'compare' => '!=',
'value' => 1
],
[
'key' => 'TestFriseur',
'compare' => 'NOT EXISTS'
]
],
]);
// Orders query (using the users IDs from the user query)
$orders = wc_get_orders([
'limit' => - 1,
'status' => ['on-hold','processing','completed'],
'customer_id' => $user_ids,
]);
// Loop through Order IDs
foreach( $orders as $order ) {
// Get the Order ID
echo $order_id = $order->get_id();
// And so on …
}
但不幸的是没有达到预期的结果。有什么建议吗?
【问题讨论】:
-
对我的回答的一些反馈总是很感激。请阅读What should I do when someone answers my question?确定答案是否有帮助,如果我的答案有效,您可以accept它和/或upvote它。
标签: wordpress woocommerce orders usermetadata