# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- HEAD
+++ Modified In Working Tree
@@ -297,16 +308,10 @@
   // Now for each model, check the stock
   foreach ($cart_items as $model => $cart_item) {
     $item = $cart_item['item'];
-    $stockinfo = uc_out_of_stock_getstockinfo_from_model($model);
-    if ($stockinfo) {
-      if ($stockinfo['stock'] - $cart_item['qty'] < 0) {
-        $qty = 0;
-        if ($page == 'checkout') {
-          $qty = $cart_item['qty'];
-        }
-        $error = _uc_out_of_stock_get_error('not_enough', $item->nid, $item->data['attributes'], $stockinfo['stock'], $qty);
-        form_set_error("items][{$cart_item['key']}][qty", $error['msg']);
-      }
+    $qty = ($page == 'checkout') ? $cart_item['qty'] : 0;
+    $error = uc_out_of_stock_validate_addtocart($item->nid, $item->data['attributes'], $qty);
+    if ($error !== FALSE) {
+      form_set_error('uc_out_of_stock', $error['msg']);
     }
   }
 
