Only return product by SKU if published

Fixes #14480
This commit is contained in:
Claudio Sanches 2017-04-18 21:32:52 -03:00
parent d94f3883da
commit f61646d1a2
1 changed files with 3 additions and 1 deletions

View File

@ -822,7 +822,9 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
FROM $wpdb->posts AS posts
LEFT JOIN $wpdb->postmeta AS postmeta ON ( posts.ID = postmeta.post_id )
WHERE posts.post_type IN ( 'product', 'product_variation' )
AND postmeta.meta_key = '_sku' AND postmeta.meta_value = '%s'
AND posts.post_status = 'publish'
AND postmeta.meta_key = '_sku'
AND postmeta.meta_value = '%s'
LIMIT 1
", $sku ) );
}