[API] Added error message when try search a product with a invalid SKU

This commit is contained in:
claudiosmweb 2014-11-27 10:52:24 -02:00
parent 553fe744cf
commit fb955e8a40
1 changed files with 4 additions and 0 deletions

View File

@ -1824,6 +1824,10 @@ class WC_API_Products extends WC_API_Resource {
public function get_product_by_sku( $sku, $fields = null ) {
$id = wc_get_product_id_by_sku( $sku );
if ( empty( $id ) ) {
return new WP_Error( 'woocommerce_api_invalid_product_sku', __( 'Invalid product SKU', 'woocommerce' ), array( 'status' => 404 ) );
}
return $this->get_product( $id, $fields );
}