Merge pull request #7793 from Nils-Fredrik/master
[API] Query products by SKU #7592
This commit is contained in:
commit
b3492c310d
|
@ -519,6 +519,18 @@ class WC_API_Products extends WC_API_Resource {
|
|||
if ( ! empty( $args['category'] ) ) {
|
||||
$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 );
|
||||
|
||||
|
|
Loading…
Reference in New Issue