--- uc_discounts.module	2009-11-26 18:21:46.000000000 +0100
+++ /home/sites/boutique.cdip.com/sites/all/modules/uc_discounts_alt/uc_discounts/uc_discounts.module	2010-03-18 12:15:19.000000000 +0100
@@ -49,7 +49,7 @@ define("CALCULATE_DISCOUNT_RESPONSE_LINE
 define("CALCULATE_DISCOUNT_RESPONSE_ERRORS_KEY", "errors");
 define("CALCULATE_DISCOUNT_RESPONSE_MESSAGES_KEY", "messages");
 
-
+include_once './sites/all/modules/includes/functions.inc';
 ///////////////////////////////////////////////////////////////////
 //Drupal Hooks
 ///////////////////////////////////////////////////////////////////
@@ -314,7 +314,7 @@ function uc_discounts_cart_pane($items) 
   //Calculate subtotal with discounts
   $subtotal = 0;
   if (is_array($items)) {
-    foreach ($items as $item) $subtotal += $item->price * $item->qty;
+    foreach ($items as $item) $subtotal += get_uc_price($item);
   }
   $total_discount_amount = 0;
   if (is_array($discounts)) {
@@ -1000,7 +1000,7 @@ function get_discounts_for_order($order,
       }
 
       uc_discounts_add_to_existing_map_number_value($order_product_id_subtotal_map,
-        $nid, $product->price * $product->qty
+        $nid, get_uc_price($product)
       );
       uc_discounts_add_to_existing_map_number_value($order_product_id_quantity_map, $nid, $product->qty);
 
@@ -1011,7 +1011,7 @@ function get_discounts_for_order($order,
       $a[] = $product;
       $order_product_id_product_array_map[$nid] = $a;
 
-      $order_subtotal += $product->price * $product->qty;
+      $order_subtotal += get_uc_price($product);
     }
     if (is_array($kits) &&  !empty($kits)) {
       foreach ($kits as $kit_id => $value) {
@@ -1392,7 +1392,7 @@ function get_discounts_for_order($order,
         $order_and_discount_product_ids = array_intersect($discount_product_ids, $order_product_ids);
         foreach ($order->products as $this_product) {
           if (in_array($this_product->nid, $order_and_discount_product_ids)) {
-            $this_product_price = $this_product->price;
+            $this_product_price = get_uc_price($this_product);
             $product_sum = $product_sum + $this_product_price;
           }
         }
@@ -1438,7 +1438,7 @@ function get_discounts_for_order($order,
           $discount_count = min($cheapest_product->qty, $free_items_remaining);
 
           //Add current discount amount to running total
-          $discount_amount += $discount_count * $cheapest_product->price;
+          $discount_amount += $discount_count * get_uc_price($cheapest_product,1);
 
           //Mark item fully discounted
           $cheapest_product->uc_discounts_is_fully_discounted = TRUE;
@@ -1509,7 +1509,7 @@ function get_discounts_for_order($order,
         if (count($discount_product_ids) > 0) {
           $discounted_products_amount = 0;
           foreach ($order_and_discount_products as $product) {
-            $discounted_products_amount += $product->price * $product->qty;
+            $discounted_products_amount += get_uc_price($product);
           }
           $discount->amount = $discounted_products_amount * $discount->discount_amount;
           // Discount the subtotal so far
@@ -1527,7 +1527,11 @@ function get_discounts_for_order($order,
       case DISCOUNT_TYPE_FIXED_AMOUNT_OFF_PER_QUALIFYING_ITEM:
         //Discount is the total quantity of qualifying items in order (order_qualifying_amount)
         //times the discount amount
-        $discount->amount = $discount->discount_amount * $order_qualifying_amount;
+		$order_and_discount_product_ids = array_intersect($discount_product_ids, $order_product_ids);
+        foreach ($order->products as $this_product)
+          if (in_array($this_product->nid, $order_and_discount_product_ids))
+            $discount->amount+=$this_product->qty;
+		$discount->amount*=$discount->discount_amount;
         break;
     }
 
