Index: uc_multi_stock.module =================================================================== --- uc_multi_stock.module (revision 4171) +++ uc_multi_stock.module (working copy) @@ -258,25 +258,26 @@ function theme_uc_multi_stock_too_many_i // code from Inventory API & Simple Stock Levels // // ////////////////////////////////////////////// -function uc_multi_get_sku($nid, $attributes) -{ - if (is_array($attributes) and count($attributes) > 0) - { +function uc_multi_get_sku($nid, $attributes) { + // The default model should be the node's SKU ALL THE TIME + // There's a chance that a combination of attributes has the same SKU + // as the one, in which case, the combination will not be found but we still + // have to return the proper SKU, which should default to the node's SKU + $product = node_load($nid); + $model = $product->model; + + if (is_array($attributes) and count($attributes) > 0) { // There are attributes so the model (SKU) is dependant on the combo of // attributes, so get all the sub products and find the attribute combo // to match what we've been passed - foreach(uc_multi_get_subproducts($nid) as $product) - if(_uc_array_same($product['attributes'], $attributes)) - return $product['model']; + foreach(uc_multi_get_subproducts($nid) as $product) { + if(_uc_array_same($product['attributes'], $attributes)) { + $model = $product['model']; } - else - { - // NO attributes so get SKU from the products node - $product = node_load($nid); - - return $product->model; } - return false; + } + + return $model; } /**