This commit is contained in:
Paul Sealock 2019-01-29 11:28:58 +13:00
parent 370a747c2b
commit 41bec03880
3 changed files with 10 additions and 9 deletions

View File

@ -61,10 +61,10 @@ class WC_Admin_REST_Reports_Customers_Controller extends WC_REST_Reports_Control
$args['last_order_before'] = $request['last_order_before'];
$args['last_order_after'] = $request['last_order_after'];
$numeric_between_params = array( 'orders_count', 'total_spend', 'avg_order_value' );
$date_between_params = array( 'last_active', 'registered' );
$normalized = WC_Admin_Reports_Interval::normalize_between_params( $request, $numeric_between_params, false );
$normalized_dates = WC_Admin_Reports_Interval::normalize_between_params( $request, $date_between_params, true );
$between_params_numeric = array( 'orders_count', 'total_spend', 'avg_order_value' );
$between_params_date = array( 'last_active', 'registered' );
$normalized = WC_Admin_Reports_Interval::normalize_between_params( $request, $between_params_numeric, false );
$normalized_dates = WC_Admin_Reports_Interval::normalize_between_params( $request, $between_params_date, true );
$args = array_merge( $args, $normalized, $normalized_dates );
return $args;

View File

@ -56,10 +56,10 @@ class WC_Admin_REST_Reports_Customers_Stats_Controller extends WC_REST_Reports_C
$args['last_order_before'] = $request['last_order_before'];
$args['last_order_after'] = $request['last_order_after'];
$numeric_between_params = array( 'orders_count', 'total_spend', 'avg_order_value' );
$date_between_params = array( 'last_active', 'registered' );
$normalized = WC_Admin_Reports_Interval::normalize_between_params( $request, $numeric_between_params, false );
$normalized_dates = WC_Admin_Reports_Interval::normalize_between_params( $request, $date_between_params, true );
$between_params_numeric = array( 'orders_count', 'total_spend', 'avg_order_value' );
$between_params_date = array( 'last_active', 'registered' );
$normalized = WC_Admin_Reports_Interval::normalize_between_params( $request, $between_params_numeric, false );
$normalized_dates = WC_Admin_Reports_Interval::normalize_between_params( $request, $between_params_date, true );
$args = array_merge( $args, $normalized, $normalized_dates );
return $args;

View File

@ -494,7 +494,8 @@ class WC_Admin_Reports_Interval {
}
/**
* Normalize "*_between" parameters to "*_min" and "*_max".
* Normalize "*_between" parameters to "*_min" and "*_max" for numeric values
* and "*_after" and "*_before" for date values.
*
* @param array $request Query params from REST API request.
* @param string|array $param_names One or more param names to handle. Should not include "_between" suffix.