--- uc_minpercentrateNew.module	2009-11-05 16:41:46.000000000 -0500
+++ uc_minpercentrate.module	2009-07-05 00:58:08.000000000 -0400
@@ -71,7 +71,7 @@ function uc_minpercentrate_form_alter(&$
         '#type' => 'textfield',
         '#title' => $method->title,
         '#default_value' => $form['#node']->minpercentrate[$method->mid],
-        '#description' => t('Default rate: %rate', array('%rate' => $method->percent_rate)),
+        '#description' => t('Default rate: %rate', array('%rate' => uc_currency_format($method->minpercent_rate))),
         '#size' => 16,
         '#field_suffix' => '%',
         '#weight' => $weight['minpercentrate_'. $method->mid],
@@ -93,10 +93,6 @@ function uc_minpercentrate_nodeapi(&$nod
             db_query("DELETE FROM {uc_minpercentrate_products} WHERE vid = %d", $node->vid);
           }
           foreach ($node->minpercentrate as $mid => $rate) {
-            if ($rate == -1) {
-              $method = db_fetch_object(db_query('SELECT percent_rate FROM {uc_minpercentrate_methods} WHERE mid=%d', $mid));
-              $rate = $method->percent_rate;
-            }
             if ($rate !== '') {
               db_query("INSERT INTO {uc_minpercentrate_products} (vid, nid, mid, rate) VALUES (%d, %d, %d, %f)",
                 $node->vid, $node->nid, $mid, $rate);
@@ -206,33 +202,33 @@ function uc_minpercentrate_shipping_meth
 function uc_minpercentrate_quote($products, $details, $method) {
   $method = explode('_', $method['id']);
   $mid = $method[1];
-  if($method = db_fetch_object(db_query("SELECT * FROM {uc_minpercentrate_methods} WHERE mid = %d", $mid))) {
+  if ($method = db_fetch_object(db_query("SELECT * FROM {uc_minpercentrate_methods} WHERE mid = %d", $mid))) {
+
     foreach ($products as $product) {
-      if($product->minpercentrate[$mid]) {
-        $percent_rate = $product->minpercentrate[$mid];
-      }
-      else {
-        $percent_rate = $method->percent_rate;
-      }
-      $product_total = $product->price * $product->qty; 
-      // keep track of the total cost of the products in this order, so that we can make 
-      // the total shipping cost free if it's higher than $method->free_rate
-      $sub_total += $product_total;
-      $product_ship_price = ($percent_rate / 100) * $product_total;
-  		if ($product_ship_price < $method->base_rate ) {
-  		  $product_ship_price = $method->base_rate; 
-  		} 
-      $total_ship_price += $product_ship_price;
-    }
-    if($method->free_rate <= $sub_total) {  
-	    $total_ship_price =  0 ;
-	  }
-  }
-  if ($total_ship_price != 0) {
-    $quotes[] = array('rate' => $total_ship_price, 'format' => uc_currency_format($rate), 'option_label' => check_plain($method->label)); 
-  }
-  else {
-    $quotes[] = array('rate' => $total_ship_price, 'format' => 'FREE', 'option_label' => check_plain($method->label)); 
+		
+    $sub_total += $product->sell_price * $product->qty;	
+
+        $rate1 = $method->percent_rate * $sub_total / 100 ;
+		
+		if ($rate1 <= $method->base_rate ) {
+		$rate = $method->base_rate; } 
+		
+	  if($rate1 >= $method->base_rate ) {  
+		$rate = $rate1; }
+
+	  if($method->free_rate <= $sub_total) {  
+		$rate =  0 ;}
+			
+	
+	}
+
+	
+    if ($rate == 0) {
+    $quotes[] = array('rate' => $rate, 'format' => 'FREE', 'option_label' => check_plain($method->label)); }
+
+    if ($rate != 0) {
+    $quotes[] = array('rate' => $rate, 'format' => uc_currency_format($rate), 'option_label' => check_plain($method->label)); }
+ 
   }
 
   return $quotes;
