parent
c27fd5c052
commit
f218b6cfd9
|
@ -215,6 +215,12 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filter by on sale products.
|
||||||
|
if ( is_bool( $request['on_sale'] ) ) {
|
||||||
|
$on_sale_key = $request['on_sale'] ? 'post__in' : 'post__not_in';
|
||||||
|
$args[ $on_sale_key ] += wc_get_product_ids_on_sale();
|
||||||
|
}
|
||||||
|
|
||||||
// Apply all WP_Query filters again.
|
// Apply all WP_Query filters again.
|
||||||
if ( is_array( $request['filter'] ) ) {
|
if ( is_array( $request['filter'] ) ) {
|
||||||
$args = array_merge( $args, $request['filter'] );
|
$args = array_merge( $args, $request['filter'] );
|
||||||
|
@ -2766,6 +2772,12 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
|
||||||
'sanitize_callback' => 'wc_string_to_bool',
|
'sanitize_callback' => 'wc_string_to_bool',
|
||||||
'validate_callback' => 'rest_validate_request_arg',
|
'validate_callback' => 'rest_validate_request_arg',
|
||||||
);
|
);
|
||||||
|
$params['on_sale'] = array(
|
||||||
|
'description' => __( 'Limit result set to products on sale.', 'woocommerce' ),
|
||||||
|
'type' => 'boolean',
|
||||||
|
'sanitize_callback' => 'wc_string_to_bool',
|
||||||
|
'validate_callback' => 'rest_validate_request_arg',
|
||||||
|
);
|
||||||
$params['min_price'] = array(
|
$params['min_price'] = array(
|
||||||
'description' => __( 'Limit result set to products based on a minimum price.', 'woocommerce' ),
|
'description' => __( 'Limit result set to products based on a minimum price.', 'woocommerce' ),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
|
|
Loading…
Reference in New Issue