您可以使用以下查询获取订单总数。
$order_totals = apply_filters( \'woocommerce_reports_sales_overview_order_totals\', $wpdb->get_row( "
SELECT COUNT(posts.ID) AS total_orders FROM {$wpdb->posts} AS posts
LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID=rel.object_ID
LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )
LEFT JOIN {$wpdb->terms} AS term USING( term_id )
WHERE meta.meta_key = \'_order_total\'
AND posts.post_type = \'shop_order\'
AND posts.post_status = \'publish\'
AND tax.taxonomy = \'shop_order_status\'
AND term.slug IN (\'" . implode( "\',\'",
apply_filters( \'woocommerce_reports_order_statuses\',
array( \'completed\', \'processing\', \'on-hold\' ) ) ) . "\')
" ) );
$total_orders_count = absint( $order_totals->total_orders );