--- uc_ratequote.module	2008-04-30 12:24:19.000000000 -0500
+++ uc_ratequote_new.module	2008-04-30 14:16:49.000000000 -0500
@@ -106,7 +106,7 @@ function uc_ratequote_admin_settings(){
   $form['rates'] = array(
     '#tree' => true
   );
-  $result = db_query("SELECT * FROM {uc_ratequotes}");
+  $result = db_query("SELECT qid FROM {uc_ratequotes}");
   while ($r = db_fetch_object($result)) {
     $qid = $r->qid;
     $form['rates'][$qid]['delete'] = array(
@@ -256,22 +256,24 @@ function uc_ratequote_configuration(){
  */
 function uc_ratequote_quote($products, $details){
   $rate = 0;
+
+  // use the product information to calculate the total order
   foreach ($products as $product){
-    $node = node_load($product->nid);
-    $total += $node->sell_price * $product->qty;
+    $total += ($product->qty * $product->price);
   }
-  $result = db_query("SELECT * FROM {uc_ratequotes}");
+
+  $result = db_query("SELECT rate,percent FROM {uc_ratequotes} WHERE min <= %f AND max >= %f", $total, $total);
   while ($r = db_fetch_object($result)) {
-    if($total <= $r->max && $total >= $r->min) {
-       $rate = $r->rate;
-      $percent = $r->percent;
-# debug
-#      ob_start(); print_r($r);
-#      drupal_set_message(ob_get_contents());
-#       ob_end_clean();
-    }
+    $rate = $r->rate;
+    $percent = $r->percent;
   }
   
+  # debug
+  /*
+        ob_start(); print_r($products);
+        drupal_set_message(ob_get_contents());
+        ob_end_clean();  
+  */
   $method = uc_ratequote_shipping_method();
   
   if ($rate > 0) {

