WC_API_Orders::get_orders_count()
Get the total number of orders
Method of the class: WC_API_Orders{}
No Hooks.
Return
Array|WP_Error
.
Usage
$WC_API_Orders = new WC_API_Orders(); $WC_API_Orders->get_orders_count( $status, $filter );
- $status(string)
- -
Default: null - $filter(array)
- -
Default: array()
Changelog
Since 2.1 | Introduced. |
WC_API_Orders::get_orders_count() WC API Orders::get orders count code WC 7.7.0
public function get_orders_count( $status = null, $filter = array() ) { if ( ! empty( $status ) ) { $filter['status'] = $status; } $query = $this->query_orders( $filter ); if ( ! current_user_can( 'read_private_shop_orders' ) ) { return new WP_Error( 'woocommerce_api_user_cannot_read_orders_count', __( 'You do not have permission to read the orders count', 'woocommerce' ), array( 'status' => 401 ) ); } return array( 'count' => (int) $query->found_posts ); }