From 7f8aa07cdce49e09f032209b1f03b2854ace5465 Mon Sep 17 00:00:00 2001 From: kidinov Date: Tue, 20 Jun 2023 12:46:53 +0200 Subject: [PATCH] Added `filter_empty` parameter --- .../API/Reports/Customers/Controller.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/plugins/woocommerce/src/Admin/API/Reports/Customers/Controller.php b/plugins/woocommerce/src/Admin/API/Reports/Customers/Controller.php index 5809fc67986..cd0eccb33d0 100644 --- a/plugins/woocommerce/src/Admin/API/Reports/Customers/Controller.php +++ b/plugins/woocommerce/src/Admin/API/Reports/Customers/Controller.php @@ -73,6 +73,7 @@ class Controller extends GenericController implements ExportableInterface { $args['customers'] = $request['customers']; $args['users'] = $request['users']; $args['force_cache_refresh'] = $request['force_cache_refresh']; + $args['filter_empty'] = $request['filter_empty']; $between_params_numeric = array( 'orders_count', 'total_spend', 'avg_order_value' ); $normalized_params_numeric = TimeInterval::normalize_between_params( $request, $between_params_numeric, false ); @@ -522,6 +523,25 @@ class Controller extends GenericController implements ExportableInterface { 'type' => 'integer', ), ); + $params['filter_empty'] = array( + 'description' => __( 'Filter out results where all passed fields are empty', 'woocommerce' ), + 'type' => 'array', + 'validate_callback' => 'rest_validate_request_arg', + 'items' => array( + 'type' => array( + 'description' => __( 'Fields that required to be not empty', 'woocommerce' ), + 'type' => 'string', + 'enum' => array( + 'email', + 'name', + 'country', + 'city', + 'region', + 'postcode', + ), + ) + ), + ); return $params; }