diff --git a/includes/api/class-wc-api-coupons.php b/includes/api/class-wc-api-coupons.php index 791cd181242..b53aea7c98d 100644 --- a/includes/api/class-wc-api-coupons.php +++ b/includes/api/class-wc-api-coupons.php @@ -156,14 +156,13 @@ class WC_API_Coupons extends WC_API_Resource { * @return array */ public function get_coupons_count( $filter = array() ) { - try { - $query = $this->query_coupons( $filter ); - if ( ! current_user_can( 'read_private_shop_coupons' ) ) { throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_coupons_count', __( 'You do not have permission to read the coupons count', 'woocommerce' ), 401 ); } + $query = $this->query_coupons( $filter ); + return array( 'count' => (int) $query->found_posts ); } catch ( WC_API_Exception $e ) { return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );