有关的文档wc_get_orders
and WC_Order_Query
很差…现在关于a中的订单状态WC_Order_Query
, you can pass an array of order statuses:
// Display "completed" orders count
$statuses = [\'completed\'];
$orders = wc_get_orders( [\'limit\' => -1, \'status\' => $statuses] );
echo \'<p>\' . sprintf( __(\'Count of "%s" orders: %s\'), implode(\'", "\', $statuses), count($orders) ) . \'</p>\';
// Display "refunded" orders count
$statuses = [\'refunded\'];
$orders = wc_get_orders( [\'limit\' => -1, \'status\' => $statuses] );
echo \'<p>\' . sprintf( __(\'Count of "%s" orders: %s\'), implode(\'", "\', $statuses), count($orders) ) . \'</p>\';
// Display "completed" and "refunded" orders count
$statuses = [\'completed\',\'refunded\'];
$orders = wc_get_orders( [\'limit\' => -1, \'status\' => $statuses] );
echo \'<p>\' . sprintf( __(\'Count of "%s" orders: %s\'), implode(\'", "\', $statuses), count($orders) ) . \'</p>\';
已测试并正常工作。