Merge branch 'fix/749' of github.com:woocommerce/wc-admin into fix/749
This commit is contained in:
commit
41efde0b23
|
@ -52,8 +52,8 @@ class WC_Admin_REST_Reports_Orders_Stats_Controller extends WC_REST_Reports_Cont
|
||||||
$args['status_is_not'] = (array) $request['status_is_not'];
|
$args['status_is_not'] = (array) $request['status_is_not'];
|
||||||
$args['product_includes'] = (array) $request['product_includes'];
|
$args['product_includes'] = (array) $request['product_includes'];
|
||||||
$args['product_excludes'] = (array) $request['product_excludes'];
|
$args['product_excludes'] = (array) $request['product_excludes'];
|
||||||
$args['code_includes'] = (array) $request['code_includes'];
|
$args['coupon_includes'] = (array) $request['coupon_includes'];
|
||||||
$args['code_excludes'] = (array) $request['code_excludes'];
|
$args['coupon_excludes'] = (array) $request['coupon_excludes'];
|
||||||
$args['customer'] = $request['customer'];
|
$args['customer'] = $request['customer'];
|
||||||
$args['categories'] = (array) $request['categories'];
|
$args['categories'] = (array) $request['categories'];
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@ class WC_Admin_REST_Reports_Orders_Stats_Controller extends WC_REST_Reports_Cont
|
||||||
'validate_callback' => 'rest_validate_request_arg',
|
'validate_callback' => 'rest_validate_request_arg',
|
||||||
);
|
);
|
||||||
$params['match'] = array(
|
$params['match'] = array(
|
||||||
'description' => __( 'Indicates whether all the conditions should be true for the resulting set, or if any one of them is sufficient. Match affects the following parameters: status_is, status_is_not, product_includes, product_excludes, code_includes, code_excludes, customer, categories', 'wc-admin' ),
|
'description' => __( 'Indicates whether all the conditions should be true for the resulting set, or if any one of them is sufficient. Match affects the following parameters: status_is, status_is_not, product_includes, product_excludes, coupon_includes, coupon_excludes, customer, categories', 'wc-admin' ),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'default' => 'all',
|
'default' => 'all',
|
||||||
'enum' => array(
|
'enum' => array(
|
||||||
|
@ -353,7 +353,7 @@ class WC_Admin_REST_Reports_Orders_Stats_Controller extends WC_REST_Reports_Cont
|
||||||
'default' => array(),
|
'default' => array(),
|
||||||
'sanitize_callback' => 'wp_parse_id_list',
|
'sanitize_callback' => 'wp_parse_id_list',
|
||||||
);
|
);
|
||||||
$params['code_includes'] = array(
|
$params['coupon_includes'] = array(
|
||||||
'description' => __( 'Limit result set to items that have the specified coupon(s) assigned.', 'wc-admin' ),
|
'description' => __( 'Limit result set to items that have the specified coupon(s) assigned.', 'wc-admin' ),
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'items' => array(
|
'items' => array(
|
||||||
|
@ -362,7 +362,7 @@ class WC_Admin_REST_Reports_Orders_Stats_Controller extends WC_REST_Reports_Cont
|
||||||
'default' => array(),
|
'default' => array(),
|
||||||
'sanitize_callback' => 'wp_parse_id_list',
|
'sanitize_callback' => 'wp_parse_id_list',
|
||||||
);
|
);
|
||||||
$params['code_excludes'] = array(
|
$params['coupon_excludes'] = array(
|
||||||
'description' => __( 'Limit result set to items that don\'t have the specified coupon(s) assigned.', 'wc-admin' ),
|
'description' => __( 'Limit result set to items that don\'t have the specified coupon(s) assigned.', 'wc-admin' ),
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'items' => array(
|
'items' => array(
|
||||||
|
|
|
@ -247,7 +247,7 @@ class WC_Admin_REST_Reports_Products_Controller extends WC_REST_Reports_Controll
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
$params['match'] = array(
|
$params['match'] = array(
|
||||||
'description' => __( 'Indicates whether all the conditions should be true for the resulting set, or if any one of them is sufficient. Match affects the following parameters: status_is, status_is_not, product_includes, product_excludes, code_includes, code_excludes, customer, categories', 'wc-admin' ),
|
'description' => __( 'Indicates whether all the conditions should be true for the resulting set, or if any one of them is sufficient. Match affects the following parameters: status_is, status_is_not, product_includes, product_excludes, coupon_includes, coupon_excludes, customer, categories', 'wc-admin' ),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'default' => 'all',
|
'default' => 'all',
|
||||||
'enum' => array(
|
'enum' => array(
|
||||||
|
|
|
@ -31,6 +31,15 @@ class WC_Admin_REST_Reports_Products_Stats_Controller extends WC_REST_Reports_Co
|
||||||
*/
|
*/
|
||||||
protected $rest_base = 'reports/products/stats';
|
protected $rest_base = 'reports/products/stats';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mapping between external parameter name and name used in query class.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $param_mapping = array(
|
||||||
|
'products' => 'product_includes',
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*/
|
*/
|
||||||
|
@ -54,9 +63,14 @@ class WC_Admin_REST_Reports_Products_Stats_Controller extends WC_REST_Reports_Co
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ( array_keys( $this->get_collection_params() ) as $arg ) {
|
$registered = array_keys( $this->get_collection_params() );
|
||||||
if ( isset( $request[ $arg ] ) ) {
|
foreach ( $registered as $param_name ) {
|
||||||
$query_args[ $arg ] = $request[ $arg ];
|
if ( isset( $request[ $param_name ] ) ) {
|
||||||
|
if ( isset( $this->param_mapping[ $param_name ] ) ) {
|
||||||
|
$query_args[ $this->param_mapping[ $param_name ] ] = $request[ $param_name ];
|
||||||
|
} else {
|
||||||
|
$query_args[ $param_name ] = $request[ $param_name ];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -286,8 +286,8 @@ class WC_Admin_Reports_Orders_Data_Store extends WC_Admin_Reports_Data_Store imp
|
||||||
'status_is_not' => array(),
|
'status_is_not' => array(),
|
||||||
'product_includes' => array(),
|
'product_includes' => array(),
|
||||||
'product_excludes' => array(),
|
'product_excludes' => array(),
|
||||||
'code_includes' => array(),
|
'coupon_includes' => array(),
|
||||||
'code_excludes' => array(),
|
'coupon_excludes' => array(),
|
||||||
'customer' => '',
|
'customer' => '',
|
||||||
'categories' => array(),
|
'categories' => array(),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue