--- uc_product_minmax.module	2010-01-26 17:44:28.000000000 -0600
+++ uc_product_minmax-new.module	2010-02-25 17:11:47.000000000 -0600
@@ -227,10 +227,36 @@ function uc_product_minmax_add_to_cart($
       'message' => theme('item_list', $message),
     );
   }
+  else {
+    $items = uc_cart_get_contents();
+    foreach ($items as $item) {
+      if ($nid == $item->nid) {
+        $qty = $qty + $item->qty;
+        if ($qty < $minmaxresult->product_min) {
+          $fail = 1;
+          $message[] = t('The minimum order quantity for this item is @qty.', array('@qty' => $minmaxresult->product_min));
+        }
+        if ($minmaxresult->pmin_multiple && $qty % $minmaxresult->pmin_multiple != 0) {
+          $fail = 1;
+          $message[] = t('This item must be ordered in multiples of @qty.', array('@qty' => $minmaxresult->pmin_multiple));
+        }
+        if ($minmaxresult->product_max && $qty > $minmaxresult->product_max && $minmaxresult->product_max != 0) {
+          $fail = 1;
+          $message[] = t('The maximum order quantity for this item is @qty.', array('@qty' => $minmaxresult->product_max));
+        }
+        if ($fail) {
+          $message[] = t('Please check your quantity and try again.');
+          $result[] = array(
+            'success' => FALSE,
+            'message' => theme('item_list', $message),
+          );
+        }
+      }
+    }
+  }
   return $result;
 }
 
-
 /**
  * Implementation of hook_checkout_pane().
  */
@@ -403,6 +429,45 @@ function uc_product_minmax_form_alter(&$
       $form['qty']['#description'] = $output;
     }
   }
+  
+  if ($form_id == 'uc_cart_view_form') {
+    $form['#validate'][] = 'uc_product_minmax_qty_validate';
+  }
+}
+
+function uc_product_minmax_qty_validate($form, &$form_state) {
+  foreach ($form_state['values']['items'] as &$item) {
+    if ($item['remove'] != 1) {
+      $nid = $item['nid'];
+      $qty = $item['qty'];
+      
+      $minmaxresult = db_fetch_object(db_query("SELECT * FROM {uc_product_minmax} WHERE nid = %s", $nid));
+      $fail = 0;
+      if ($qty < $minmaxresult->product_min && $qty > 0) {
+        $fail = 1;
+        $message[] = t('The minimum order quantity for this item is @qty.', array('@qty' => $minmaxresult->product_min));
+      }
+      if ($minmaxresult->pmin_multiple && $qty % $minmaxresult->pmin_multiple != 0) {
+        $fail = 1;
+        $message[] = t('This item must be ordered in multiples of @qty.', array('@qty' => $minmaxresult->pmin_multiple));
+      }
+      if ($minmaxresult->product_max && $qty > $minmaxresult->product_max && $minmaxresult->product_max != 0) {
+        $fail = 1;
+        $message[] = t('The maximum order quantity for this item is @qty.', array('@qty' => $minmaxresult->product_max));
+      }
+      if ($fail) {
+        $message[] = t('Please check your quantity and try again.');
+        $result[] = array(
+          'success' => FALSE,
+          'message' => theme('item_list', $message),
+        );
+      }
+
+      if ($fail == 1) {
+        form_set_error('items', $message[0]);
+      }
+    }
+  }
 }
 
 /*******************************************************************************
