=== modified file 'uc_discount.module'
--- uc_discount.module	2009-03-13 14:30:16 +0000
+++ uc_discount.module	2009-04-09 18:16:07 +0000
@@ -52,22 +52,28 @@
   }
 }
 
-function uc_discount_nodeapi(&$node, $op, $arg3 = NULL, $arg4 = NULL) {
-  switch ($op) {
-    case 'load':
-      global $user;
-
-      if (uc_product_is_product($node)) {
-        ca_pull_trigger('calculate_product_discounts', $node, $user);
-      }
-      break;
-  }
-}
-
 /******************************************************************************
  * Ubercart hooks                                                             *
  ******************************************************************************/
 
+function uc_discount_uc_price_handler() {
+  return array(
+    'alter' => array(
+      'callback' => 'uc_discount_price_handler_alter',
+    ),
+  );
+}
+
+function uc_discount_price_handler_alter(&$price, &$context, &$options) {
+  global $user;
+  if (isset($context['subject']['node'])) {
+    $node = $context['subject']['node'];
+    ca_pull_trigger('calculate_product_discounts', $node, $user);
+
+    $price['value'] = $node->sell_price;
+  }
+}
+
 /**
  * Update and save discount line items to the order.
  */
@@ -642,17 +648,19 @@
   foreach ($predicates as $predicate) {
     if (ca_evaluate_conditions($predicate, $arguments)) {
       $discounts = ca_perform_actions($predicate, $arguments);
-      foreach ($discounts as $i => $discount) {
-        if ($predicate['#actions'][$i]['#name'] == 'uc_discount_action_get_order_discount' && $discount) {
-          // Allow successive discounts to inspect this discount by putting
-          // it in the order object.
-          $order->discounts[$id] = array(
-            'id' => $id,
-            'title' => check_plain($predicate['#actions'][$i]['#title']),
-            'amount' => $discount,
-            'weight' => $predicate['#actions'][$i]['#settings']['line_item_weight'],
-          );
-          $id++;
+      if (is_array($discounts)) {
+        foreach ($discounts as $i => $discount) {
+          if ($predicate['#actions'][$i]['#name'] == 'uc_discount_action_get_order_discount' && $discount) {
+            // Allow successive discounts to inspect this discount by putting
+            // it in the order object.
+            $order->discounts[$id] = array(
+              'id' => $id,
+              'title' => check_plain($predicate['#actions'][$i]['#title']),
+              'amount' => $discount,
+              'weight' => $predicate['#actions'][$i]['#settings']['line_item_weight'],
+            );
+            $id++;
+          }
         }
       }
     }

