WC_Order_Data_Store_CPT::get_order_count()publicWC 1.0

Return count of orders with a specific status.

Method of the class: WC_Order_Data_Store_CPT{}

No Hooks.

Return

Int.

Usage

$WC_Order_Data_Store_CPT = new WC_Order_Data_Store_CPT();
$WC_Order_Data_Store_CPT->get_order_count( $status );
$status(string) (required)
Order status. Function wc_get_order_statuses() returns a list of valid statuses.

WC_Order_Data_Store_CPT::get_order_count() code WC 9.3.3

public function get_order_count( $status ) {
	global $wpdb;
	return absint( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( * ) FROM {$wpdb->posts} WHERE post_type = 'shop_order' AND post_status = %s", $status ) ) );
}