Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableDataStore::get_order_count()publicWC 1.0

Return count of orders with a specific status.

Method of the class: OrdersTableDataStore{}

No Hooks.

Return

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() code WC 7.1.0

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
}