Index: uc_price_per_role.install
===================================================================
--- uc_price_per_role.install	(revision 94)
+++ uc_price_per_role.install	(working copy)
@@ -6,6 +6,8 @@
  */
 function uc_price_per_role_install() {
   drupal_install_schema('uc_price_per_role');
+  
+  db_query("UPDATE {system} SET weight='-20' WHERE name='uc_price_per_role'");
 }
 
 /**
Index: uc_price_per_role.module
===================================================================
--- uc_price_per_role.module	(revision 94)
+++ uc_price_per_role.module	(working copy)
@@ -529,12 +529,61 @@
 }
 
 /**
+ * Implementation of hook_order_product_alter().
+ */
+function uc_price_per_role_order_product_alter(&$product, $order) {
+  // Only do this if it is a cart item, if not, return now
+  if (!isset($product->type)) {
+    return;
+  }
+  
+  // Load the account for the order
+  $account = user_load($order->uid);
+  
+  // Load the product node
+  $product_node = node_load($product->nid);
+  
+  // Get the price for the order account's roles
+  $result = db_query("SELECT rid, price FROM {uc_price_per_role_prices} WHERE vid = %d", $product_node->vid);
+  $prices = array();
+  while ($row = db_fetch_object($result)) {
+    $prices[$row->rid] = $row->price;
+  }
+
+  $price = uc_price_per_role_find_price($prices, $account);
+  if ($price !== FALSE) {
+    $product->price = $price;
+  }
+  
+  // Adjust the price based on the attribute prices for the account's roles
+  if (module_exists('uc_attribute')) {
+    $role_prices = uc_price_per_role_load_option_prices($product->nid);
+    $cost = 0;
+    foreach (_uc_cart_product_get_options($product) as $option) {
+      $oid = $option['oid'];
+      $price = uc_price_per_role_find_price($role_prices[$oid], $account);
+      if ($price !== FALSE) {
+        $cost += $price;
+      }
+    }
+    
+    // Set the cost and adjust the price for the attributes
+    $product->cost = $cost;
+    $product->price += $cost;
+  }
+}
+
+/**
  * Find the price for the current user from the supplied price array.
  * 
  * Will return FALSE if no price was found.
  */
-function uc_price_per_role_find_price($prices) {
+function uc_price_per_role_find_price($prices, $account = NULL) {
   global $user;
+  
+  if (!isset($account)) {
+    $account = $user;
+  }
 
   $enabled = variable_get('uc_price_per_role_enabled', array());
   $weights = variable_get('uc_price_per_role_weights', array());
@@ -547,7 +596,7 @@
 
   // Otherwise, look for a matching role.
   foreach ($weights as $rid => $weight) {
-    if (isset($user->roles[$rid]) && $enabled[$rid] && isset($prices[$rid])) {
+    if (isset($account->roles[$rid]) && $enabled[$rid] && isset($prices[$rid])) {
       return $prices[$rid];
     }
   }
