Merge pull request #7793 from Nils-Fredrik/master

[API] Query products by SKU #7592
This commit is contained in:
Claudio Sanches 2015-03-23 11:39:32 -03:00
commit b3492c310d
1 changed files with 12 additions and 0 deletions

View File

@ -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 );