--- uc_discounts_alt/uc_discounts/uc_discounts.module	2009-11-26 18:21:45.000000000 +0100
+++ /home/sites/boutique.cdip.com/sites/all/modules/uc_discounts_alt/uc_discounts/uc_discounts.module	2010-03-11 17:27:52.000000000 +0100
@@ -49,6 +49,27 @@ define("CALCULATE_DISCOUNT_RESPONSE_LINE
 define("CALCULATE_DISCOUNT_RESPONSE_ERRORS_KEY", "errors");
 define("CALCULATE_DISCOUNT_RESPONSE_MESSAGES_KEY", "messages");
 
+/**
++ * Returns the price for a product including Tax, if using uc_vat module
++ *
++ * @param object $item
++ */
+function get_uc_price($item) {
+  $price_info = array(
+    'price' => $item->price,
+    'qty' => $item->qty,
+  );
+  $context = array(
+    'type' => 'cart_item',
+    'revision' => 'altered',
+    'subject' => array(
+      'cart_item' => $item,
+      'node' => node_load($item->nid),
+    ),
+  );
+  return uc_price($price_info, $context);
+}
+
 
 ///////////////////////////////////////////////////////////////////
 //Drupal Hooks
@@ -314,7 +335,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)) {
@@ -378,7 +399,7 @@ function uc_checkout_pane_discounts($op,
       //Add form to checkout pane
 
       $description = t("Enter discount codes in the box below (one per line).");
-
+	  
       //If viewing an existing order, load order's codes
       if (!empty($arg1->order_id)) {
         $codes_string = uc_discounts_order_codes_get($arg1->order_id);
@@ -402,7 +423,7 @@ function uc_checkout_pane_discounts($op,
         "#type" => "button",
         "#value" => t("Click to calculate discounts"),
       );
-
+	  
       drupal_add_js(array(
           "uc_discounts" => array(
             "line_item_key_name" => LINE_ITEM_KEY_NAME,
@@ -531,7 +552,7 @@ function uc_discounts_js_calculate() {
   $messages   = array();
 
   $discounts = get_discounts_for_order($order, $errors, $warnings, $messages);
-
+  
   $i = 0;
   foreach ($discounts as $discount) {
     $line_item           = array();
@@ -1000,7 +1021,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 +1032,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) {
@@ -1509,7 +1530,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
