Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableDataStore::get_order_count()publicWC 1.0

Return count of orders with a specific status.

Метод класса: OrdersTableDataStore{}

Хуков нет.

Возвращает

int.

Использование

$OrdersTableDataStore = new OrdersTableDataStore();
$OrdersTableDataStore->get_order_count( $status );
$status(строка) (обязательный)
Order status. Function wc_get_order_statuses() returns a list of valid statuses.

Код OrdersTableDataStore::get_order_count() WC 8.7.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
}