Fix for #7592
Added sku filter to the /products endpoint. Will let you search for products by sku without using the /products/sku/<sku> endpoint. Its now possible to search for product skus with specialchars like / and -.
This commit is contained in:
parent
17fb3874e6
commit
686c40919b
|
@ -520,6 +520,18 @@ class WC_API_Products extends WC_API_Resource {
|
|||
$query_args['product_cat'] = $args['category'];
|
||||
}
|
||||
|
||||
// filter by specific sku
|
||||
if( ! empty( $args['sku'] ) ) {
|
||||
if(!is_array($query_args['meta_query'])) {
|
||||
$query_args['meta_query'] = array();
|
||||
}
|
||||
$query_args['meta_query'][] = array(
|
||||
'key' => '_sku',
|
||||
'value' => $args['sku'],
|
||||
'compare' => "="
|
||||
);
|
||||
}
|
||||
|
||||
$query_args = $this->merge_query_args( $query_args, $args );
|
||||
|
||||
return new WP_Query( $query_args );
|
||||
|
|
Loading…
Reference in New Issue