Automattic\WooCommerce\Internal\DataStores\Orders
OrdersTableDataStore::get_order_count
Return count of orders with a specific status.
Method of the class: OrdersTableDataStore{}
No Hooks.
Returns
Int.
Usage
$OrdersTableDataStore = new OrdersTableDataStore(); $OrdersTableDataStore->get_order_count( $status );
- $status(string) (required)
- Order status. Function wc_get_order_statuses() returns a list of valid statuses.
OrdersTableDataStore::get_order_count() OrdersTableDataStore::get order count code WC 10.3.3
public function get_order_count( $status ) {
global $wpdb;
$orders_table = self::get_orders_table_name();
return absint( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$orders_table} WHERE type = %s AND status = %s", 'shop_order', $status ) ) ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
}