Index: uc_discount.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uc_discount/uc_discount.module,v
retrieving revision 1.7
diff -u -r1.7 uc_discount.module
--- uc_discount.module	20 May 2009 15:09:41 -0000	1.7
+++ uc_discount.module	12 Jun 2009 20:42:40 -0000
@@ -50,6 +50,25 @@
       drupal_add_js(drupal_get_path('module', 'uc_discount') .'/uc_discount.js');
     }
   }
+  else {
+    $triggers = array_keys(uc_discount_ca_trigger());
+
+    if ($form_id == 'ca_predicate_meta_form') {
+      if ($predicate = ca_load_predicate($form['predicate_pid']['#value']) && in_array($predicate['#trigger'], $triggers)) {
+        $form['#submit'][] = 'uc_discount_clear_price_cache';
+      }
+    }
+    elseif ($form_id == 'ca_conditions_form' || $form_id == 'ca_actions_form') {
+      if ($predicate = ca_load_predicate($form['pid']['#value']) && in_array($predicate['#trigger'], $triggers)) {
+        if ($form_id == 'ca_conditions_form') {
+          $form['save']['#submit'][] = 'uc_discount_clear_price_cache';
+        }
+        else {
+          $form['submit']['#submit'][] = 'uc_discount_clear_price_cache';
+        }
+      }
+    }
+  }
 }
 
 /******************************************************************************
@@ -319,6 +338,19 @@
 }
 
 /**
+ * hook_cart_item
+ */
+function uc_discount_cart_item($op, &$item) {
+  switch ($op) {
+    case 'load':
+      global $user;
+
+      ca_pull_trigger('calculate_product_discounts', $item, $user);
+      break;
+  }
+}
+
+/**
  * Allows discounts based on the order total.
  *
  * This discount does not have any settings, so it does not provide a form.
@@ -729,3 +761,12 @@
   }
   exit();
 }
+
+/**
+ * Form submit callback for discount CA predicates.
+ *
+ * Changes to discount conditions or actions invalidate cached prices.
+ */
+function uc_discount_clear_price_cache() {
+  cache_clear_all(NULL, 'cache_uc_price');
+}
