Index: userpoints_ubercart/uc_userpoints_payment.module
===================================================================
--- userpoints_ubercart/uc_userpoints_payment.module	(revision 18)
+++ userpoints_ubercart/uc_userpoints_payment.module	(working copy)
@@ -11,10 +11,8 @@ define('USERPOINTS_PAY_CATEGORY', 'userp
 function uc_userpoints_payment_help($path, $arg) {
   switch ($path) {
     case 'admin/modules#description':
-      $output = t('<strong>Userpoints Payment:</strong> Interfaces userpoints with Ubercart so users can make purchases with points.');
-      break;
+      return t('<strong>Userpoints Payment:</strong> Interfaces userpoints with Ubercart so users can make purchases with points.');
   }
-  return $output;
 }
 
 /**
@@ -50,7 +48,7 @@ function uc_userpoints_payment_userpoint
           '#type' => 'radios',
           '#title' => t('Moderate userpoints transaction'),
           '#default_value' => variable_get(USERPOINTS_PAY_MODERATE, 0),
-					'#options' => array(t('No'), t('Yes')),
+          '#options' => array(t('No'), t('Yes')),
         );
         $form[$group][USERPOINTS_PAY_DISPLAY] = array(
           '#type' => 'radios',
@@ -114,42 +112,42 @@ function uc_userpoints_payment_userpoint
 function uc_userpoints_payment_nodeapi(&$node, $op, $arg3, $arg4) {
   switch ($op){
     case 'view':
-		if ($node->type=='product') {
-			$dispStyle = variable_get(USERPOINTS_DISPLAY,2);
-			//disp 1=dollars, 2=both, 3=points
-
-			if (module_exists('uc_userpoints_product')) {
-			  $points = db_result(db_query("SELECT points FROM {uc_userpoints_products} WHERE nid = %d", $node->nid));
-			  if ($points > 0) {
-			    $dispStyle = 1; // you can't buy a point product with points
-			  }
-			}
-	
+    if ($node->type=='product') {
+      $dispStyle = variable_get(USERPOINTS_DISPLAY,2);
+      //disp 1=dollars, 2=both, 3=points
+
+      if (module_exists('uc_userpoints_product')) {
+        $points = db_result(db_query("SELECT points FROM {uc_userpoints_products} WHERE nid = %d", $node->nid));
+        if ($points > 0) {
+          $dispStyle = 1; // you can't buy a point product with points
+        }
+      }
+
       $pointCost = ceil($node->sell_price * variable_get(USERPOINTS_UC_PAYMENT, 1));
-			switch($dispStyle) {
-				case 1: 
-					//do nothing since we only want dollars
-					//$node->content['sell_price']['#value'] = '$$';
-					//$node->content['display_price']['#value'] = '$$';
-					break;
-				case 2: 
-					$node->content['sell_price']['#value'] .= '<div class="sell_price">' . t('!Points: ' . $pointCost, userpoints_translation()) . '</div>';
-					$node->content['display_price']['#value'] .= '<div class="display_price">' . t('!Points: ' . $pointCost, userpoints_translation()) . '</div>';
-					break;
-				case 3: 
-					$node->content['sell_price']['#value'] = '<div class="sell_price">' . t('!Points: ' . $pointCost, userpoints_translation()) . '</div>';
-					$node->content['display_price']['#value'] = '<div class="display_price">' . t('!Points: ' . $pointCost, userpoints_translation()) . '</div>';
-					break;
-			}
-			
-		}
-	}
+      switch($dispStyle) {
+        case 1:
+          //do nothing since we only want dollars
+          //$node->content['sell_price']['#value'] = '$$';
+          //$node->content['display_price']['#value'] = '$$';
+          break;
+        case 2:
+          $node->content['sell_price']['#value'] .= '<div class="sell_price">' . t('!Points: ' . $pointCost, userpoints_translation()) . '</div>';
+          $node->content['display_price']['#value'] .= '<div class="display_price">' . t('!Points: ' . $pointCost, userpoints_translation()) . '</div>';
+          break;
+        case 3:
+          $node->content['sell_price']['#value'] = '<div class="sell_price">' . t('!Points: ' . $pointCost, userpoints_translation()) . '</div>';
+          $node->content['display_price']['#value'] = '<div class="display_price">' . t('!Points: ' . $pointCost, userpoints_translation()) . '</div>';
+          break;
+      }
+
+    }
+  }
 }
 
 /**
  * Implementation of hook_payment_method().
  */
- 
+
 function uc_userpoints_payment_payment_method() {
   global $user;
 
@@ -183,34 +181,34 @@ function uc_userpoints_payment_payment_m
 /**
  * Implementation of hook_order().
  */
- 
+
 function uc_userpoints_payment_order($op, &$arg1, $arg2) {
   $order 	 = $arg1;
   $paymethod = strtolower($order->payment_method);
   switch ($op) {
-		case 'submit':
-			// fires when the order is submitted and adds/subtracts thier points
-			if ($paymethod == 'points') {
-				uc_userpoints_payment_payment($order);
-			}
-			break;
-		case 'update':
-			// if the order is canceled we need to refund thier points because we are too lazy to do it by hand...
-			if ($arg2 == 'canceled') {
-				if (strtolower($order->payment_method) == 'points') {
-					uc_userpoints_payment_refund($order);
-				}
-			}
-			break;
-		case 'delete':	
-		  if (strtolower($order->payment_method) == 'points') {
-			uc_userpoints_payment_refund($order);
-	  	  }
-		  break;
-		case 'can_delete';
-		  return FALSE;
-	  	break;
-	  }
+    case 'submit':
+      // fires when the order is submitted and adds/subtracts thier points
+      if ($paymethod == 'points') {
+        uc_userpoints_payment_payment($order);
+      }
+      break;
+    case 'update':
+      // if the order is canceled we need to refund thier points because we are too lazy to do it by hand...
+      if ($arg2 == 'canceled') {
+        if (strtolower($order->payment_method) == 'points') {
+          uc_userpoints_payment_refund($order);
+        }
+      }
+      break;
+    case 'delete':
+      if (strtolower($order->payment_method) == 'points') {
+      uc_userpoints_payment_refund($order);
+        }
+      break;
+    case 'can_delete';
+      return FALSE;
+      break;
+    }
 }
 
 /**
@@ -234,17 +232,17 @@ function uc_userpoints_translation() {
 
 function uc_payment_method_points($op, &$arg1) {
   switch ($op) {
-		case 'cart-details':
-			/**
-			 *  Eventually I want to hide the points discount if its enabled.
-			 **/
-			return;
-			break;
-		case 'cart-process':
+    case 'cart-details':
+      /**
+       *  Eventually I want to hide the points discount if its enabled.
+       **/
+      return;
+      break;
+    case 'cart-process':
       $user_points = userpoints_get_current_points($arg1->uid, variable_get(USERPOINTS_PAY_CATEGORY, NULL));
       $order_points = ceil($arg1->order_total * variable_get(USERPOINTS_UC_PAYMENT, 1));
 
-			if ($user_points < $order_points) {
+      if ($user_points < $order_points) {
         if (variable_get(USERPOINTS_PAY_DISPLAY, 1)) {
           // Display point amounts
           if (variable_get(USERPOINTS_DISPLAY, 2) == 1) {
@@ -258,22 +256,22 @@ function uc_payment_method_points($op, &
           // Hide point amounts
           drupal_set_message(t('You do not have enough !points to complete this purchase. Please select another payment method.', array_merge(uc_userpoints_translation(), array('@user_points' => $user_points, '@order_points' => $order_points))), 'error');
         }
-				return FALSE;
-				break;
-			}
-			else
-			{
-				return TRUE;
-				break;
-			}
-			break;
-		case 'settings':
-			// Add a few points related fields to the payment methods settings form.
-			$form['userpoints_ubercart_permission'] = array(
-				'#value' => '<div>'. t('Please adjust the settings for using points under the userpoints section '.l('userpoints admin settings','admin/settings/userpoints').'.  This area is for enabling points as payment method only.') .'</div>',
-		);
-			return $form;
-			break;
+        return FALSE;
+        break;
+      }
+      else
+      {
+        return TRUE;
+        break;
+      }
+      break;
+    case 'settings':
+      // Add a few points related fields to the payment methods settings form.
+      $form['userpoints_ubercart_permission'] = array(
+        '#value' => '<div>'. t('Please adjust the settings for using points under the userpoints section '.l('userpoints admin settings','admin/settings/userpoints').'.  This area is for enabling points as payment method only.') .'</div>',
+    );
+      return $form;
+      break;
   }
 }
 
@@ -284,25 +282,25 @@ function uc_userpoints_payment_payment($
   $description = t('Order #!order_id paid with !points', array_merge(uc_userpoints_translation(), array('!order_id' => $order->order_id)));
 
   if ($order === FALSE || uc_order_status_data($order->order_status, 'state') != 'in_checkout') {
-		print t('An error has occurred during payment.  Please contact us to ensure your order has submitted.');
-		exit();
+    print t('An error has occurred during payment.  Please contact us to ensure your order has submitted.');
+    exit();
   }
 
-  if ($order->payment_method == 'points') {  
-		$params = array (
-			'tid' => variable_get(USERPOINTS_PAY_CATEGORY, NULL),
-			'uid' => $order->uid,
-			'points' => -$points,
-			'operation' => 'purchase',
-			'description' => $description,
-			'entity_id' => $order->order_id,
-			'entity_type' => 'uc_order',
-			'moderate' => variable_get(USERPOINTS_PAY_MODERATE, 0),
+  if ($order->payment_method == 'points') {
+    $params = array (
+      'tid' => variable_get(USERPOINTS_PAY_CATEGORY, NULL),
+      'uid' => $order->uid,
+      'points' => -$points,
+      'operation' => 'purchase',
+      'description' => $description,
+      'entity_id' => $order->order_id,
+      'entity_type' => 'uc_order',
+      'moderate' => variable_get(USERPOINTS_PAY_MODERATE, 0),
       'display' => variable_get(USERPOINTS_PAY_DISPLAY, 1),
-		);
-		userpoints_userpointsapi($params);
-		uc_payment_enter($order->order_id, 'points', $order->order_total, $user->uid, NULL, $description);
-		db_query("insert into {uc_up_payment_log} (uid, oid, points) values(%d, %d, %d)", $order->uid, $order->order_id, $points);
+    );
+    userpoints_userpointsapi($params);
+    uc_payment_enter($order->order_id, 'points', $order->order_total, $user->uid, NULL, $description);
+    db_query("insert into {uc_up_payment_log} (uid, oid, points) values(%d, %d, %d)", $order->uid, $order->order_id, $points);
   }
 }
 
@@ -312,26 +310,26 @@ function uc_userpoints_payment_refund($o
   $oid 			= $order->order_id;
   $result 		= db_query("select uplog_id, points from {uc_up_payment_log} where oid = %d and uid = %d", $oid, $curUserId);
   $orderTotal	= $order->order_total;
-  
+
   if ($result != FALSE) {
     $pointinfo = db_fetch_object($result);
     $points = intval((($pointinfo->points) * (-1)));
-		$description	= 'User purchase (Ubercart Order ' . $order->order_id .') has been canceled.';
-	
-		db_query("delete from {uc_payment_receipts} where method = 'Points' and order_id = %d", $oid);
-		db_query("delete from {uc_up_payment_log} where uplog_id = %d", $pointinfo->uplog_id);
-		
-		$params = array (
-			'tid' => variable_get('USERPOINTS_PAY_CATEGORY', NULL),
-			'uid' => $curUserId,
-			'points' => $points,
-			'operation' => 'refund',
-			'description' => $description,
-			'entity_id' => $oid,
-			'entity_type' => 'uc_order',
-			'moderate' => variable_get(USERPOINTS_PAY_MODERATE, 0),
+    $description	= 'User purchase (Ubercart Order ' . $order->order_id .') has been canceled.';
+
+    db_query("delete from {uc_payment_receipts} where method = 'Points' and order_id = %d", $oid);
+    db_query("delete from {uc_up_payment_log} where uplog_id = %d", $pointinfo->uplog_id);
+
+    $params = array (
+      'tid' => variable_get('USERPOINTS_PAY_CATEGORY', NULL),
+      'uid' => $curUserId,
+      'points' => $points,
+      'operation' => 'refund',
+      'description' => $description,
+      'entity_id' => $oid,
+      'entity_type' => 'uc_order',
+      'moderate' => variable_get(USERPOINTS_PAY_MODERATE, 0),
       'display' => variable_get(USERPOINTS_PAY_DISPLAY, 1),
-		);
-		userpoints_userpointsapi($params);
+    );
+    userpoints_userpointsapi($params);
   }
 }
Index: userpoints_ubercart/uc_userpoints_product.module
===================================================================
--- userpoints_ubercart/uc_userpoints_product.module	(revision 18)
+++ userpoints_ubercart/uc_userpoints_product.module	(working copy)
@@ -8,93 +8,91 @@ define('USERPOINTS_PRODUCT_MODERATE',	'u
 define('USERPOINTS_PRODUCT_CATEGORY',	'userpoints_product_category');
 
 function uc_userpoints_product_help($path, $arg) {
-    switch ($path) {
-      case 'admin/modules#description':
-        $output = t('<strong>Ubercart Userpoints Product:</strong> Interfaces userpoints with Ubercart, so users can purchase points with products.');
-      break;
-    }
-    return $output;
+  switch ($path) {
+    case 'admin/modules#description':
+      return t('<strong>Ubercart Userpoints Product:</strong> Interfaces userpoints with Ubercart, so users can purchase points with products.');
+  }
 }
 
 
 function uc_userpoints_product_userpoints($op, $params = array()) {
-	switch($op) {
-	  case 'setting':
-	    if (module_exists('uc_cart') && module_exists('uc_payment')) {
-		  $group = 'uc_userpoints_product';
-		  $form[$group] = array(
-		    '#type' => 'fieldset',
-			'#collapsible' => TRUE,
-			'#collapsed' => TRUE,
-			'#title' => t('Ubercart Product Options'),
-		  );
-		  $form[$group][USERPOINTS_PRODUCT_MODERATE] = array(
-		    '#type' => 'radios',
-			'#title' => t('Moderate userpoints transaction'),
-			'#default_value' => variable_get(USERPOINTS_PRODUCT_MODERATE, 0), 
-			'#options' => array(t('No'), t('Yes')),
-		  );
-		  $form[$group][USERPOINTS_PRODUCT_CATEGORY] = array(
-		    '#type' => 'select',
-			'#title' => t('Product Category'),
-			'#default_value' => variable_get(USERPOINTS_PRODUCT_CATEGORY, NULL),
-			'#options' => userpoints_get_categories(),
-			'#description' => t('Default category to assign awarded !points. This can be overridden on a per product basis', userpoints_translation()),
-	      );
-		}
-		return $form;
-		break;
-	}
+  switch($op) {
+    case 'setting':
+      if (module_exists('uc_cart') && module_exists('uc_payment')) {
+      $group = 'uc_userpoints_product';
+      $form[$group] = array(
+        '#type' => 'fieldset',
+      '#collapsible' => TRUE,
+      '#collapsed' => TRUE,
+      '#title' => t('Ubercart Product Options'),
+      );
+      $form[$group][USERPOINTS_PRODUCT_MODERATE] = array(
+        '#type' => 'radios',
+      '#title' => t('Moderate userpoints transaction'),
+      '#default_value' => variable_get(USERPOINTS_PRODUCT_MODERATE, 0),
+      '#options' => array(t('No'), t('Yes')),
+      );
+      $form[$group][USERPOINTS_PRODUCT_CATEGORY] = array(
+        '#type' => 'select',
+      '#title' => t('Product Category'),
+      '#default_value' => variable_get(USERPOINTS_PRODUCT_CATEGORY, NULL),
+      '#options' => userpoints_get_categories(),
+      '#description' => t('Default category to assign awarded !points. This can be overridden on a per product basis', userpoints_translation()),
+        );
+    }
+    return $form;
+    break;
+  }
 }
 
 
 function uc_userpoints_product_product_feature() {
-	$features[] = array(
-		'id' => 'userpoints',
-		'title' => t(variable_get(USERPOINTS_TRANS_UCPOINTS, 'Userpoints')),
-		'callback' => 'uc_userpoints_product_feature_form',
-		'delete' => 'uc_userpoints_product_feature_delete',
-		'settings' => array('uc_userpoints_product_feature_settings'),
-	);
-	return $features;
+  $features[] = array(
+    'id' => 'userpoints',
+    'title' => t(variable_get(USERPOINTS_TRANS_UCPOINTS, 'Userpoints')),
+    'callback' => 'uc_userpoints_product_feature_form',
+    'delete' => 'uc_userpoints_product_feature_delete',
+    'settings' => array('uc_userpoints_product_feature_settings'),
+  );
+  return $features;
 }
 
 /**
 * Build the userpoints feature form
 */
 function uc_userpoints_product_feature_form($node, $feature) {
-	$points = 0;
+  $points = 0;
 
-	$nid = arg(1);
+  $nid = arg(1);
 
-	$res = db_query("SELECT * FROM {uc_userpoints_products} ucup, {uc_product_features} ucpf WHERE ucup.pfid = ucpf.pfid AND ucup.nid = %d",$nid);
-	while ($pf = db_fetch_object($res)) {
-	  $points = $pf->points;
-	  $tid = $pf->tid;
-	}
-	
-	$category_options = userpoints_get_categories();
-	$category_options[-1] = t('Default '.variable_get(USERPOINTS_TRANS_LCPOINTS, 'Points').' Product Category');
-
-	$form['nid'] = array(
-		'#type' => 'value',
-		'#value' => $nid,
-	);
-	$form['points'] = array(
-		'#type' => 'textfield',
-		'#title' => t('Number of '.variable_get(USERPOINTS_TRANS_LCPOINTS, 'points')),
-		'#description' => t('How many '.variable_get(USERPOINTS_TRANS_LCPOINTS, 'points').' to give when this product is purchased.'),
-		'#default_value' => $points,
-	);
-	$form['tid'] = array(
-		'#type' => 'select',
-		'#title' => t('Product Category'),
-		'#default_value' => $tid,
-		'#options' => $category_options,
-		'#description' => t('Category to assign awarded !points. If you choose \'Default '.variable_get(USERPOINTS_TRANS_LCPOINTS, 'Points').' Product Category\', the category on your '.l(t('Ubercart Product Options'), 'admin/settings/userpoints').' settings page will be used.', userpoints_translation()),
-	 );
+  $res = db_query("SELECT * FROM {uc_userpoints_products} ucup, {uc_product_features} ucpf WHERE ucup.pfid = ucpf.pfid AND ucup.nid = %d",$nid);
+  while ($pf = db_fetch_object($res)) {
+    $points = $pf->points;
+    $tid = $pf->tid;
+  }
+
+  $category_options = userpoints_get_categories();
+  $category_options[-1] = t('Default '.variable_get(USERPOINTS_TRANS_LCPOINTS, 'Points').' Product Category');
 
-	return uc_product_feature_form($form);
+  $form['nid'] = array(
+    '#type' => 'value',
+    '#value' => $nid,
+  );
+  $form['points'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Number of '.variable_get(USERPOINTS_TRANS_LCPOINTS, 'points')),
+    '#description' => t('How many '.variable_get(USERPOINTS_TRANS_LCPOINTS, 'points').' to give when this product is purchased.'),
+    '#default_value' => $points,
+  );
+  $form['tid'] = array(
+    '#type' => 'select',
+    '#title' => t('Product Category'),
+    '#default_value' => $tid,
+    '#options' => $category_options,
+    '#description' => t('Category to assign awarded !points. If you choose \'Default '.variable_get(USERPOINTS_TRANS_LCPOINTS, 'Points').' Product Category\', the category on your '.l(t('Ubercart Product Options'), 'admin/settings/userpoints').' settings page will be used.', userpoints_translation()),
+   );
+
+  return uc_product_feature_form($form);
 }
 
 
@@ -109,35 +107,35 @@ function uc_userpoints_product_feature_f
 * Submit the form
 */
 function uc_userpoints_product_feature_form_submit($form, &$form_state) {
-	if ($form_state['values']['tid'] >= 0) {
-		$term = taxonomy_get_term($form_state['values']['tid']);
-		$term_name = $term->name;
-	} elseif ($form_state['values']['tid'] == '-1'){
-		$term_name = l(t('Default '.variable_get(USERPOINTS_TRANS_LCPOINTS, 'Points').' Product Category'), 'admin/settings/userpoints');
-	}
-	
-	$term = taxonomy_get_term($form_state['values']['tid']);
-	$data = array(
-		'pfid' => $form_state['values']['pfid'],
-		'nid' => $form_state['values']['nid'],
-		'points' => $form_state['values']['points'],
-		'tid' => $form_state['values']['tid'],
-		'fid' => 'userpoints',
-		'description' => 'Product is now worth '.$form_state['values']['points'].' '.variable_get(USERPOINTS_TRANS_LCPOINTS, 'points').', assigned to the \''. $term_name .'\' category',
-	);
-	
-	$ret = uc_product_feature_save($data);
-	if (empty($data['pfid'])) {
-		$pf = db_fetch_object(db_query("select pfid from {uc_product_features} where nid = %d and fid = %d",$data['nid'],$data['fid']));
-		$data['pfid'] = $pf->pfid;
-
-		db_query("INSERT INTO {uc_userpoints_products} (pfid,nid,points,tid) VALUES (%d,%d,%d,%d)",$data['pfid'],$data['nid'],$data['points'],$data['tid']);
-	}
-	else {
-		db_query("UPDATE {uc_userpoints_products} SET points = %d, tid= %d WHERE nid = %d AND pfid = %d",$data['points'],$data['tid'],$data['nid'],$data['pfid']);
-	}
+  if ($form_state['values']['tid'] >= 0) {
+    $term = taxonomy_get_term($form_state['values']['tid']);
+    $term_name = $term->name;
+  } elseif ($form_state['values']['tid'] == '-1'){
+    $term_name = l(t('Default '.variable_get(USERPOINTS_TRANS_LCPOINTS, 'Points').' Product Category'), 'admin/settings/userpoints');
+  }
 
-	$form_state['redirect'] = $ret;
+  $term = taxonomy_get_term($form_state['values']['tid']);
+  $data = array(
+    'pfid' => $form_state['values']['pfid'],
+    'nid' => $form_state['values']['nid'],
+    'points' => $form_state['values']['points'],
+    'tid' => $form_state['values']['tid'],
+    'fid' => 'userpoints',
+    'description' => 'Product is now worth '.$form_state['values']['points'].' '.variable_get(USERPOINTS_TRANS_LCPOINTS, 'points').', assigned to the \''. $term_name .'\' category',
+  );
+
+  $ret = uc_product_feature_save($data);
+  if (empty($data['pfid'])) {
+    $pf = db_fetch_object(db_query("select pfid from {uc_product_features} where nid = %d and fid = %d",$data['nid'],$data['fid']));
+    $data['pfid'] = $pf->pfid;
+
+    db_query("INSERT INTO {uc_userpoints_products} (pfid,nid,points,tid) VALUES (%d,%d,%d,%d)",$data['pfid'],$data['nid'],$data['points'],$data['tid']);
+  }
+  else {
+    db_query("UPDATE {uc_userpoints_products} SET points = %d, tid= %d WHERE nid = %d AND pfid = %d",$data['points'],$data['tid'],$data['nid'],$data['pfid']);
+  }
+
+  $form_state['redirect'] = $ret;
 }
 
 
@@ -145,7 +143,7 @@ function uc_userpoints_product_feature_f
  * Feature settings
  */
 function uc_userpoints_product_feature_settings() {
-	// Nothing yet.
+  // Nothing yet.
 }
 
 
@@ -153,8 +151,8 @@ function uc_userpoints_product_feature_s
  * Product Feature delete function
  */
 function uc_userpoints_product_feature_delete($feature) {
-		db_query("DELETE FROM {uc_userpoints_products} WHERE pfid = %d",$feature['pfid']);
-		db_query("DELETE FROM {uc_product_features} WHERE pfid = %d", $feature['pfid']);
+    db_query("DELETE FROM {uc_userpoints_products} WHERE pfid = %d",$feature['pfid']);
+    db_query("DELETE FROM {uc_product_features} WHERE pfid = %d", $feature['pfid']);
 }
 
 
@@ -163,48 +161,48 @@ function uc_userpoints_product_feature_d
  */
 function uc_userpoints_product_order($op, $order, $status) {
 
-	switch ($op) {
-		case 'update':
-		// We might want to add the "Order Status" to the Userpoints Ubercart options...
-			if (($status == 'completed' && $order->uid > 0) && ($order_user = user_load(array('uid' => $order->uid))) !== FALSE) {
-				$totalPoints = 0; // this will be the total order points
-				foreach ($order->products as $product) {
-					$productPoints = 0; // This will be the product points * quantity
-					$points = db_result(db_query("SELECT sum(points) FROM {uc_userpoints_products} WHERE nid = %d", $product->nid));
-					$tid = db_result(db_query("SELECT tid FROM {uc_userpoints_products} WHERE nid = %d", $product->nid));
-					if ($points > 0) {
-						//drupal_set_message($product->title.' has '.$points.' '.variable_get(USERPOINTS_TRANS_LCPOINTS, 'points').' attached');
-						$productPoints = ($product->qty * $points); // Make sure we account for multiple qty of the Points product
-					}
-					if (($tid == '') || ($tid == '-1')) {
-			            $tid = variable_get(USERPOINTS_PRODUCT_CATEGORY, 0);
-			        }
-			    
-			    $params = array (
-				    'tid' => $tid,
-				    'uid' => $order->uid,
-				    'points' => $productPoints,
-				    'operation' => 'add',
-				    'description' => t('A user purchased !product containing !amount points.', array('!product' => l($product->title, 'node/' . $product->nid), '!amount' => $productPoints)),
-				    'entity_id' => $order->oid,
-				    'entity_type' => 'Ubercart Transaction',
-				    'moderate' => variable_get(USERPOINTS_PRODUCT_MODERATE, 0),
-			    );
-			
-				$totalPoints += $productPoints;
-				
-		        if ($productPoints > 0) {
-					userpoints_userpointsapi($params);
-					uc_order_comment_save($order->order_id, 0, t('User bought '.$productPoints.' points with product: '. $product->title .'!'), 'admin'); //Order comment per product points
-				}
-				}
-				if ($totalPoints > 0) {
-				  uc_order_comment_save($order->order_id, 0, t('User bought a total of '.$totalPoints.' points on this order!'), 'admin'); //Order comment on total points
-				}
-		    }
-		    
-	break;
-	}
+  switch ($op) {
+    case 'update':
+    // We might want to add the "Order Status" to the Userpoints Ubercart options...
+      if (($status == 'completed' && $order->uid > 0) && ($order_user = user_load(array('uid' => $order->uid))) !== FALSE) {
+        $totalPoints = 0; // this will be the total order points
+        foreach ($order->products as $product) {
+          $productPoints = 0; // This will be the product points * quantity
+          $points = db_result(db_query("SELECT sum(points) FROM {uc_userpoints_products} WHERE nid = %d", $product->nid));
+          $tid = db_result(db_query("SELECT tid FROM {uc_userpoints_products} WHERE nid = %d", $product->nid));
+          if ($points > 0) {
+            //drupal_set_message($product->title.' has '.$points.' '.variable_get(USERPOINTS_TRANS_LCPOINTS, 'points').' attached');
+            $productPoints = ($product->qty * $points); // Make sure we account for multiple qty of the Points product
+          }
+          if (($tid == '') || ($tid == '-1')) {
+                  $tid = variable_get(USERPOINTS_PRODUCT_CATEGORY, 0);
+              }
+
+          $params = array (
+            'tid' => $tid,
+            'uid' => $order->uid,
+            'points' => $productPoints,
+            'operation' => 'add',
+            'description' => t('A user purchased !product containing !amount points.', array('!product' => l($product->title, 'node/' . $product->nid), '!amount' => $productPoints)),
+            'entity_id' => $order->oid,
+            'entity_type' => 'Ubercart Transaction',
+            'moderate' => variable_get(USERPOINTS_PRODUCT_MODERATE, 0),
+          );
+
+        $totalPoints += $productPoints;
+
+            if ($productPoints > 0) {
+          userpoints_userpointsapi($params);
+          uc_order_comment_save($order->order_id, 0, t('User bought '.$productPoints.' points with product: '. $product->title .'!'), 'admin'); //Order comment per product points
+        }
+        }
+        if ($totalPoints > 0) {
+          uc_order_comment_save($order->order_id, 0, t('User bought a total of '.$totalPoints.' points on this order!'), 'admin'); //Order comment on total points
+        }
+        }
+
+  break;
+  }
 }
 
 /**
@@ -214,7 +212,7 @@ function uc_userpoints_product_order($op
 function uc_userpoints_product_form_alter(&$form, &$form_state, $form_id) {
   // We may need to alter the checkout form to remove invalid payment methods.
   if ($form_id == 'uc_cart_checkout_form' && isset($form['panes']['payment'])) {
-           
+
     $order->products = uc_cart_get_contents();
 
     // Make no changes if no products containing Userpoints are found.
@@ -224,7 +222,7 @@ function uc_userpoints_product_form_alte
       unset($form['panes']['payment']['payment_method']['#options']['points']);
       drupal_set_message(t('You cannot purchase !points with !points, so that payment option has been removed.', userpoints_translation()),'error');
     }
-       
+
     $count = count($form['panes']['payment']['payment_method']['#options']);
     if ($count == 0) {
       // Display an error message if no payment methods remain.
Index: userpoints_ubercart/uc_userpoints_discount.module
===================================================================
--- userpoints_ubercart/uc_userpoints_discount.module	(revision 18)
+++ userpoints_ubercart/uc_userpoints_discount.module	(working copy)
@@ -17,10 +17,8 @@ define('UC_USERPOINTS_DISCOUNT_CLASSES',
 function uc_userpoints_discount_help($path, $arg) {
   switch ($path) {
     case 'admin/modules#description':
-      $output = t('<strong>Userpoints Discounts:</strong> Interfaces userpoints with Ubercart, so users can use points as a discount.');
-      break;
+      return t('<strong>Userpoints Discounts:</strong> Interfaces userpoints with Ubercart, so users can use points as a discount.');
   }
-  return $output;
 }
 
 
@@ -36,7 +34,7 @@ function uc_userpoints_discount_userpoin
           '#collapsible' => TRUE,
           '#collapsed' => TRUE,
           '#title' => t('Ubercart Discount Options'),
-        );    
+        );
         $form[$group][USERPOINTS_UC_DISC] = array(
           '#type' => 'textfield',
           '#title' => t('!Points used in discount (for every @currency)', array('!Points' => $userpoints_translation['!Points'], '@currency' => variable_get('uc_currency_code', 'USD'))),
@@ -57,25 +55,25 @@ function uc_userpoints_discount_userpoin
           '#default_value' =>  variable_get(USERPOINTS_DISCOUNT,1),
           '#options' => array(t('No'), t('Yes')),
         );
-		    $form[$group][USERPOINTS_DISCOUNT_CATEGORY] = array(
-    		  '#type' => 'select',
-    		  '#title' => t('Discount Category'),
-    		  '#description' => t('Category to assign awarded !points.', userpoints_translation()),
-    		  '#default_value' => variable_get(USERPOINTS_DISCOUNT_CATEGORY, NULL),
-    		  '#options' => userpoints_get_categories(),
-    		);
+        $form[$group][USERPOINTS_DISCOUNT_CATEGORY] = array(
+          '#type' => 'select',
+          '#title' => t('Discount Category'),
+          '#description' => t('Category to assign awarded !points.', userpoints_translation()),
+          '#default_value' => variable_get(USERPOINTS_DISCOUNT_CATEGORY, NULL),
+          '#options' => userpoints_get_categories(),
+        );
         $form[$group][UC_USERPOINTS_DISCOUNT_MODERATE] = array(
           '#type' => 'radios',
           '#title' => t('Moderate userpoints transaction'),
           '#default_value' => variable_get(UC_USERPOINTS_DISCOUNT_MODERATE, 0),
-		      '#options' => array(t('No'), t('Yes')),
+          '#options' => array(t('No'), t('Yes')),
         );
         $form[$group][UC_USERPOINTS_DISCOUNT_CLASSES] = array(
           '#type' => 'checkboxes',
           '#title' => t('Product classes discounts can be applied to'),
           '#description' => t('Leave blank for all.'),
           '#default_value' => variable_get(UC_USERPOINTS_DISCOUNT_CLASSES, array()),
-		      '#options' => uc_product_type_names(),
+          '#options' => uc_product_type_names(),
         );
       }
       return $form;
@@ -93,7 +91,7 @@ function uc_userpoints_discount_checkout
   $curUserId	 = $user->uid;
   $curUserPoints = intval(userpoints_get_current_points($uid = $curUserId, $tid = NULL));
   $discMethod	 = variable_get(USERPOINTS_DISCOUNT,1);
-    
+
   if ($discMethod != 0 && ($curUserPoints > 0 || request_uri() != '/cart/checkout')) {
     $panes[] = array(
       'id' => 'up_uc_discounts',
@@ -115,29 +113,29 @@ function uc_checkout_pane_uc_userpoints_
 
   switch ($op) {
     case 'view':
-			$curUserPoints = intval(userpoints_get_current_points($uid = $curUserId, $tid = NULL));
-			$maxdisc = ($curUserPoints / intval(variable_get(USERPOINTS_UC_DISC, 1)));
-			$maxpt = variable_get(UC_USERPOINTS_DISCOUNT_MAXP, 100);
-			$description = t('Enter the amount to discount this order with !points by. This field will be ignored if paying with !points.', userpoints_translation());
-			$description .= theme('uc_userpoints_discount_info_pane', uc_currency_format(uc_userpoints_discount_discountable_total()), uc_currency_format(uc_userpoints_discount_max()), uc_currency_format($maxdisc));
-			$contents['ptamt'] = array(
-				'#type' => 'textfield',
-				'#title' => t('Discount Amount (in @currency)', array('@currency' => variable_get('uc_currency_code', 'USD'))),
-				'#description' => t('Enter the amount that you want to spend from your !points as a discount for this order.', userpoints_translation()),
-				'#default_value' => $arg1->ptamt,
-			);
-			return array('description' => $description, 'contents' => $contents);
-			break;	
+      $curUserPoints = intval(userpoints_get_current_points($uid = $curUserId, $tid = NULL));
+      $maxdisc = ($curUserPoints / intval(variable_get(USERPOINTS_UC_DISC, 1)));
+      $maxpt = variable_get(UC_USERPOINTS_DISCOUNT_MAXP, 100);
+      $description = t('Enter the amount to discount this order with !points by. This field will be ignored if paying with !points.', userpoints_translation());
+      $description .= theme('uc_userpoints_discount_info_pane', uc_currency_format(uc_userpoints_discount_discountable_total()), uc_currency_format(uc_userpoints_discount_max()), uc_currency_format($maxdisc));
+      $contents['ptamt'] = array(
+        '#type' => 'textfield',
+        '#title' => t('Discount Amount (in @currency)', array('@currency' => variable_get('uc_currency_code', 'USD'))),
+        '#description' => t('Enter the amount that you want to spend from your !points as a discount for this order.', userpoints_translation()),
+        '#default_value' => $arg1->ptamt,
+      );
+      return array('description' => $description, 'contents' => $contents);
+      break;
     case 'process':
-			$ptamt = $arg2['ptamt'];
-			if (!empty($ptamt) || $ptamt != '') {
-				$arg1->ptamt = $ptamt;
-			}
-			else {
-				$arg1->ptamt = 0;
-			}
-			return TRUE;
-			break;
+      $ptamt = $arg2['ptamt'];
+      if (!empty($ptamt) || $ptamt != '') {
+        $arg1->ptamt = $ptamt;
+      }
+      else {
+        $arg1->ptamt = 0;
+      }
+      return TRUE;
+      break;
   }
 }
 
@@ -161,7 +159,7 @@ function uc_userpoints_discount_line_ite
 
 function uc_userpoints_discount_line_item_calc($op, $arg1) {
   $lines = array();
-  
+
   #discount value
   $ptamt = $arg1->ptamt;
 
@@ -177,7 +175,7 @@ function uc_userpoints_discount_line_ite
       return $lines;
       break;
 
-    
+
   }
 }
 
@@ -192,130 +190,130 @@ function uc_userpoints_discount_order($o
   $paymethod = strtolower($order->payment_method);
   switch ($op) {
     case 'total':
-			/**
-			 * If there is a discount apply it to the order total
-			 */
-			if (variable_get(USERPOINTS_DISCOUNT,1) != 0 && strtolower($order->payment_method) != 'points') {
-				$result = db_query("SELECT * FROM {uc_updiscounts} WHERE oid = %d", $arg1->order_id);
-				if ($data = db_fetch_object($result)) {
-					return -$data->ptamt;
-				}
-			}
-			break;
+      /**
+       * If there is a discount apply it to the order total
+       */
+      if (variable_get(USERPOINTS_DISCOUNT,1) != 0 && strtolower($order->payment_method) != 'points') {
+        $result = db_query("SELECT * FROM {uc_updiscounts} WHERE oid = %d", $arg1->order_id);
+        if ($data = db_fetch_object($result)) {
+          return -$data->ptamt;
+        }
+      }
+      break;
     case 'save':
-			db_query("DELETE FROM {uc_updiscounts} WHERE oid=%d", $arg1->order_id);
-			db_query("DELETE FROM {uc_order_line_items} WHERE order_id=%d AND type='ptdiscount'", $arg1->order_id);
-			uc_line_items_calculate($arg1->order_id);	
-			global $user;
-			$curUserId = $user->uid;
-			$pagepath = str_replace('destination=','',urldecode(drupal_get_destination()));
-			$multiplier 	= (variable_get(USERPOINTS_UC_DISC, 0));
-			$maxdisc = variable_get(UC_USERPOINTS_DISCOUNT_MAXP, 100)/100;
-
-			#discountable money value of order
-			$orderamt = uc_userpoints_discount_discountable_total() + $arg1->quote['rate'];
-
-			$curUserPoints = intval(userpoints_get_current_points($uid = $curUserId, $tid = NULL));
-			$maxdisc = ($curUserPoints / intval(variable_get(USERPOINTS_UC_DISC, 1)));
-
-			#discount value
-			$ptamt = $arg1->ptamt;
-			#discount value in points
-			$points = -(($ptamt) * $multiplier);
-			$ptdisc = (($ptamt) * $multiplier);
-			
-			#max discount on order total
-			$ptmaxd = uc_userpoints_discount_max();
-			$ptmaxdPoints = $ptmaxd * $multiplier;
-			
-			if (variable_get(USERPOINTS_DISCOUNT,1) != 0 && strtolower($order->payment_method) != 'points') {
-				if ((!empty($ptamt) || $ptamt != '') && $ptamt < $orderamt && $ptdisc <= min($curUserPoints, $ptmaxdPoints)) {
-					db_query("DELETE FROM {uc_order_line_items} WHERE order_id=%d AND type='ptdiscount'", $arg1->order_id);
-					db_query('INSERT INTO {uc_updiscounts} (uid, oid, ptamt, points) VALUES (%d, %d, \'%f\', %d)', $curUserId, $arg1->order_id, $ptamt, $points);
-					uc_order_line_item_add($arg1->order_id, 'ptdiscount', t('Discount order using !points',userpoints_translation()), -$ptamt, 1);
-				}
-				elseif ($ptdisc <= $orderamt && (!empty($ptamt) || $ptamt != '')) {
-					#this should be to check it greater than order total
-					drupal_set_message('You cannot discount an order for more than the order total.', 'error');
-					drupal_goto($pagepath);
-				}
-				elseif ($ptdisc > min($curUserPoints, $ptmaxdPoints) && (!empty($ptamt) || $ptamt != '')) {
-					#this should be to check if discount greater than max
-					drupal_set_message(t('The maximum you can discount this order by using points is %maxamount.', array('%maxamount' => uc_currency_format(min($ptmaxd, $maxdisc)))), 'error');
-					drupal_goto($pagepath);
-				}
-			}
-			elseif (strtolower($order->payment_method) == 'points' && (!empty($ptamt) || $ptamt != '')) {
-					drupal_set_message(t('You cannot use !points to pay for a product and use !points as a discount method.', userpoints_translation()), 'error');
-					drupal_goto($pagepath);
-			}
-			break;
-		case 'submit':
-			// fires when the order is submitted and adds/subtracts thier points
-			if ($paymethod != 'points') {
-				if (variable_get(USERPOINTS_DISCOUNT,1) != 0) {
-					global $user;
-					$curUserId = $user->uid;
-					$ptamt = $arg1->ptamt;
-					$multiplier 	= intval(variable_get(USERPOINTS_UC_DISC, 0));
-				
-					// Payment completed
-					if ($curUserId != 0) {
-					// User id from the transaction
-						$points = intval(($ptamt) * $multiplier);
-						$points = -$points;
-						$params = array (
-						'tid' => variable_get(USERPOINTS_DISCOUNT_CATEGORY, 0),
-						'uid' => $curUserId,
-						'points' => $points,
-						'operation' => 'delete',
-						'description' => 'User Discount, taking poings (Ubercart Order ID ' . $order->order_id . ')',
-						'entity_id' => $order->order_id,
-						'entity_type' => 'Ubercart Transaction',
-						'moderate' => variable_get(UC_USERPOINTS_DISCOUNT_MODERATE, 0),
-						);
-						userpoints_userpointsapi($params);
-					db_query('INSERT INTO {uc_updiscounts} (uid, oid, ptamt, points) VALUES (%d, %d, \'%f\', %d)', $curUserId, $arg1->order_id, $ptamt, $points);
-					}
-
-				}
-			}
-			break;
-		case 'load':
-			$arg1->ptamt = '';
-			$result = db_query("SELECT * FROM {uc_updiscounts} WHERE oid = %d", $arg1->order_id);
-			if ($data = db_fetch_object($result)) {
-				$arg1->ptamt = $data->ptamt;
-			}
-			break;
-		case 'delete':	
-			if (variable_get(USERPOINTS_DISCOUNT,1) != 0 && strtolower($order->payment_method) != 'points') {
-				global $user;
-				$curUserId	= $user->uid;
-				$oid			= $order->order_id;
-				$result 		= db_query("select updlog_id, points from {uc_updiscounts} where oid = %d and uid = %d and referrer = 0 and discount =1", $oid, $curUserId);
-
-				if ($result != FALSE && $pointinfo = db_fetch_object($result) != FALSE) {
-					$points = intval(($pointinfo->points) * (-1));
-					$description = 'User Discount (Ubercart Order ' . $oid . ') that has been deleted.';
-					
-					$params = array (
-						'tid' => variable_get(USERPOINTS_DISCOUNT_CATEGORY, 0),
-						'uid' => $curUserId,
-						'points' => $points,
-						'operation' => 'delete',
-						'description' => $description,
-						'entity_id' => $oid,
-						'entity_type' => 'Ubercart Transaction',
-						'moderate' => variable_get(UC_USERPOINTS_DISCOUNT_MODERATE, 0),
-					);
-					
-					userpoints_userpointsapi($params);
-					db_query("delete from {uc_updiscounts} where uplog_id = %d", $pointinfo->uplog_id);
-					db_query("DELETE FROM {uc_order_line_items} WHERE order_id=%d AND type='ptdiscount'", $arg1->order_id);
-				}
-			}
-			break;
+      db_query("DELETE FROM {uc_updiscounts} WHERE oid=%d", $arg1->order_id);
+      db_query("DELETE FROM {uc_order_line_items} WHERE order_id=%d AND type='ptdiscount'", $arg1->order_id);
+      uc_line_items_calculate($arg1->order_id);
+      global $user;
+      $curUserId = $user->uid;
+      $pagepath = str_replace('destination=','',urldecode(drupal_get_destination()));
+      $multiplier 	= (variable_get(USERPOINTS_UC_DISC, 0));
+      $maxdisc = variable_get(UC_USERPOINTS_DISCOUNT_MAXP, 100)/100;
+
+      #discountable money value of order
+      $orderamt = uc_userpoints_discount_discountable_total() + $arg1->quote['rate'];
+
+      $curUserPoints = intval(userpoints_get_current_points($uid = $curUserId, $tid = NULL));
+      $maxdisc = ($curUserPoints / intval(variable_get(USERPOINTS_UC_DISC, 1)));
+
+      #discount value
+      $ptamt = $arg1->ptamt;
+      #discount value in points
+      $points = -(($ptamt) * $multiplier);
+      $ptdisc = (($ptamt) * $multiplier);
+
+      #max discount on order total
+      $ptmaxd = uc_userpoints_discount_max();
+      $ptmaxdPoints = $ptmaxd * $multiplier;
+
+      if (variable_get(USERPOINTS_DISCOUNT,1) != 0 && strtolower($order->payment_method) != 'points') {
+        if ((!empty($ptamt) || $ptamt != '') && $ptamt < $orderamt && $ptdisc <= min($curUserPoints, $ptmaxdPoints)) {
+          db_query("DELETE FROM {uc_order_line_items} WHERE order_id=%d AND type='ptdiscount'", $arg1->order_id);
+          db_query('INSERT INTO {uc_updiscounts} (uid, oid, ptamt, points) VALUES (%d, %d, \'%f\', %d)', $curUserId, $arg1->order_id, $ptamt, $points);
+          uc_order_line_item_add($arg1->order_id, 'ptdiscount', t('Discount order using !points',userpoints_translation()), -$ptamt, 1);
+        }
+        elseif ($ptdisc <= $orderamt && (!empty($ptamt) || $ptamt != '')) {
+          #this should be to check it greater than order total
+          drupal_set_message('You cannot discount an order for more than the order total.', 'error');
+          drupal_goto($pagepath);
+        }
+        elseif ($ptdisc > min($curUserPoints, $ptmaxdPoints) && (!empty($ptamt) || $ptamt != '')) {
+          #this should be to check if discount greater than max
+          drupal_set_message(t('The maximum you can discount this order by using points is %maxamount.', array('%maxamount' => uc_currency_format(min($ptmaxd, $maxdisc)))), 'error');
+          drupal_goto($pagepath);
+        }
+      }
+      elseif (strtolower($order->payment_method) == 'points' && (!empty($ptamt) || $ptamt != '')) {
+          drupal_set_message(t('You cannot use !points to pay for a product and use !points as a discount method.', userpoints_translation()), 'error');
+          drupal_goto($pagepath);
+      }
+      break;
+    case 'submit':
+      // fires when the order is submitted and adds/subtracts thier points
+      if ($paymethod != 'points') {
+        if (variable_get(USERPOINTS_DISCOUNT,1) != 0) {
+          global $user;
+          $curUserId = $user->uid;
+          $ptamt = $arg1->ptamt;
+          $multiplier 	= intval(variable_get(USERPOINTS_UC_DISC, 0));
+
+          // Payment completed
+          if ($curUserId != 0) {
+          // User id from the transaction
+            $points = intval(($ptamt) * $multiplier);
+            $points = -$points;
+            $params = array (
+            'tid' => variable_get(USERPOINTS_DISCOUNT_CATEGORY, 0),
+            'uid' => $curUserId,
+            'points' => $points,
+            'operation' => 'delete',
+            'description' => 'User Discount, taking poings (Ubercart Order ID ' . $order->order_id . ')',
+            'entity_id' => $order->order_id,
+            'entity_type' => 'Ubercart Transaction',
+            'moderate' => variable_get(UC_USERPOINTS_DISCOUNT_MODERATE, 0),
+            );
+            userpoints_userpointsapi($params);
+          db_query('INSERT INTO {uc_updiscounts} (uid, oid, ptamt, points) VALUES (%d, %d, \'%f\', %d)', $curUserId, $arg1->order_id, $ptamt, $points);
+          }
+
+        }
+      }
+      break;
+    case 'load':
+      $arg1->ptamt = '';
+      $result = db_query("SELECT * FROM {uc_updiscounts} WHERE oid = %d", $arg1->order_id);
+      if ($data = db_fetch_object($result)) {
+        $arg1->ptamt = $data->ptamt;
+      }
+      break;
+    case 'delete':
+      if (variable_get(USERPOINTS_DISCOUNT,1) != 0 && strtolower($order->payment_method) != 'points') {
+        global $user;
+        $curUserId	= $user->uid;
+        $oid			= $order->order_id;
+        $result 		= db_query("select updlog_id, points from {uc_updiscounts} where oid = %d and uid = %d and referrer = 0 and discount =1", $oid, $curUserId);
+
+        if ($result != FALSE && $pointinfo = db_fetch_object($result) != FALSE) {
+          $points = intval(($pointinfo->points) * (-1));
+          $description = 'User Discount (Ubercart Order ' . $oid . ') that has been deleted.';
+
+          $params = array (
+            'tid' => variable_get(USERPOINTS_DISCOUNT_CATEGORY, 0),
+            'uid' => $curUserId,
+            'points' => $points,
+            'operation' => 'delete',
+            'description' => $description,
+            'entity_id' => $oid,
+            'entity_type' => 'Ubercart Transaction',
+            'moderate' => variable_get(UC_USERPOINTS_DISCOUNT_MODERATE, 0),
+          );
+
+          userpoints_userpointsapi($params);
+          db_query("delete from {uc_updiscounts} where uplog_id = %d", $pointinfo->uplog_id);
+          db_query("DELETE FROM {uc_order_line_items} WHERE order_id=%d AND type='ptdiscount'", $arg1->order_id);
+        }
+      }
+      break;
   }
 }
 
@@ -333,7 +331,7 @@ function uc_userpoints_discount_checkbox
     foreach($array as $row) {
       if (!empty($row)) {
         $status = TRUE;
-      } 
+      }
     }
   }
   return $status;
@@ -403,7 +401,7 @@ function uc_userpoints_discount_discount
   $discountable_products = uc_userpoints_discount_discountable_products();
   $discountable_total = 0;
   foreach($discountable_products as $discountable_product) {
-    $discountable_total += intval($discountable_product['price']) * intval($discountable_product['qty']); 
+    $discountable_total += intval($discountable_product['price']) * intval($discountable_product['qty']);
   }
   return $discountable_total;
 }
@@ -472,7 +470,7 @@ function theme_uc_userpoints_discount_in
                   '</span>
                 </div>
               </div>';
-              
+
   return $content;
 }
 
Index: userpoints_ubercart/uc_userpoints_award.module
===================================================================
--- userpoints_ubercart/uc_userpoints_award.module	(revision 18)
+++ userpoints_ubercart/uc_userpoints_award.module	(working copy)
@@ -11,10 +11,8 @@ define('USERPOINTS_REF_MODERATE',     'u
 function uc_userpoints_award_help($path, $arg) {
   switch ($path) {
     case 'admin/modules#description':
-      $output = t('<strong>Userpoints Award:</strong> Interfaces userpoints with Ubercart so users can get points for purchases.');
-      break;
+      return t('<strong>Userpoints Award:</strong> Interfaces userpoints with Ubercart so users can get points for purchases.');
   }
-  return $output;
 }
 
 function uc_userpoints_award_userpoints($op, $points = 0, $uid = 0, $event = '') {
@@ -46,7 +44,7 @@ function uc_userpoints_award_userpoints(
           '#type' => 'radios',
           '#title' => t('Moderate userpoints transaction'),
           '#default_value' => variable_get(USERPOINTS_AWARD_MODERATE, 0),
-					'#options' => array(t('No'), t('Yes')),
+          '#options' => array(t('No'), t('Yes')),
         );
         $form[$group][USERPOINTS_AWARD_CATEGORY] = array(
           '#type' => 'select',
@@ -71,12 +69,12 @@ function uc_userpoints_award_userpoints(
             '#maxlength' => 5,
             '#description' => t('Enter the number of !points awarded per dollar.  <b>This field is only valid when "Referrer and Purchaser" is selected above.  Otherwise the standard multiplier is used.</b>', userpoints_translation()),
           );
-		      $form[$group][USERPOINTS_REF_MODERATE] = array(
-			      '#type' => 'radios',
-			      '#title' => t('Moderate userpoints transaction'),
-			      '#default_value' => variable_get(USERPOINTS_REF_MODERATE, 0),
-			      '#options' => array(t('No'), t('Yes')),
-		      );
+          $form[$group][USERPOINTS_REF_MODERATE] = array(
+            '#type' => 'radios',
+            '#title' => t('Moderate userpoints transaction'),
+            '#default_value' => variable_get(USERPOINTS_REF_MODERATE, 0),
+            '#options' => array(t('No'), t('Yes')),
+          );
         }
       }
       return $form;
@@ -89,28 +87,28 @@ function uc_userpoints_award_userpoints(
  * Implementation of hook_ca_action
  */
 function uc_userpoints_award_ca_action() {
-	$order_arg = array(
-	  '#entity' => 'uc_order',
-	  '#title' => t('Order'),
-	);
-
-	$actions['uc_userpoints_buyer_award_points'] = array(
-	  '#title' => t('Award buyer points'),
-	  '#category' => t('Order'),
-	  '#callback' => 'uc_userpoints_buyer_award_points',
-	  '#arguments' => array(
-	    'order' => $order_arg,
-	  ),
-	);
+  $order_arg = array(
+    '#entity' => 'uc_order',
+    '#title' => t('Order'),
+  );
+
+  $actions['uc_userpoints_buyer_award_points'] = array(
+    '#title' => t('Award buyer points'),
+    '#category' => t('Order'),
+    '#callback' => 'uc_userpoints_buyer_award_points',
+    '#arguments' => array(
+      'order' => $order_arg,
+    ),
+  );
 
-	return $actions;
+  return $actions;
 }
 
 /**
  * Implementation of hook_ca_predicate
  **/
 function uc_userpoints_award_ca_predicate() {
-	$predicates['uc_userpoints_default_award'] = array (
+  $predicates['uc_userpoints_default_award'] = array (
   '#title' => t('Award points if order complete'),
   '#description' => '',
   '#class' => '',
@@ -118,39 +116,39 @@ function uc_userpoints_award_ca_predicat
   '#weight' => '0',
   '#uid' => '0',
   '#trigger' => 'uc_order_status_update',
-  '#conditions' => 
+  '#conditions' =>
   array (
     '#operator' => 'AND',
-    '#conditions' => 
+    '#conditions' =>
     array (
-      0 => 
+      0 =>
       array (
         '#operator' => 'AND',
-        '#conditions' => 
+        '#conditions' =>
         array (
-          0 => 
+          0 =>
           array (
             '#name' => 'uc_order_status_condition',
             '#title' => 'Check the order status',
-            '#argument_map' => 
+            '#argument_map' =>
             array (
               'order' => 'updated_order',
             ),
-            '#settings' => 
+            '#settings' =>
             array (
               'negate' => 0,
               'order_status' => 'completed',
             ),
           ),
-          1 => 
+          1 =>
           array (
             '#name' => 'uc_order_status_condition',
             '#title' => 'Check the order status',
-            '#argument_map' => 
+            '#argument_map' =>
             array (
               'order' => 'order',
             ),
-            '#settings' => 
+            '#settings' =>
             array (
               'negate' => 1,
               'order_status' => 'completed',
@@ -160,17 +158,17 @@ function uc_userpoints_award_ca_predicat
       ),
     ),
   ),
-  '#actions' => 
+  '#actions' =>
   array (
-    0 => 
+    0 =>
     array (
       '#name' => 'uc_userpoints_buyer_award_points',
       '#title' => t('Award buyer points'),
-      '#argument_map' => 
+      '#argument_map' =>
       array (
         'order' => 'updated_order',
       ),
-      '#settings' => 
+      '#settings' =>
       array (
       ),
     ),
@@ -215,52 +213,52 @@ function uc_userpoints_buyer_award_point
       }
     }
   }
-	
 
-	// Payment completed
-	// Award points to buyer, if appropriate
-	if ($curUserId != 0 && ($award_to==1 || $award_to==2) && strtolower($order->payment_method) != 'points') {
-		// User id from the transaction
-	
-		if ($total < $min) {
-			$points = 0;
-		}
-		else {
-			$points = intval(($total * $multiplier));
-			$params = array (
-				'tid' => variable_get(USERPOINTS_AWARD_CATEGORY, 0),
-				'uid' => $curUserId,
-				'points' => $points,
-				'operation' => 'insert',
-				'description' => 'User made a purchase, awarding points (Ubercart Order ID ' . $order->order_id . ')',
+
+  // Payment completed
+  // Award points to buyer, if appropriate
+  if ($curUserId != 0 && ($award_to==1 || $award_to==2) && strtolower($order->payment_method) != 'points') {
+    // User id from the transaction
+
+    if ($total < $min) {
+      $points = 0;
+    }
+    else {
+      $points = intval(($total * $multiplier));
+      $params = array (
+        'tid' => variable_get(USERPOINTS_AWARD_CATEGORY, 0),
+        'uid' => $curUserId,
+        'points' => $points,
+        'operation' => 'insert',
+        'description' => 'User made a purchase, awarding points (Ubercart Order ID ' . $order->order_id . ')',
 //				'entity_id' => $order->order_id,
 //				'entity_type' => 'Ubercart Transaction',
-				'moderate' => variable_get(USERPOINTS_AWARD_MODERATE, 0),
-			);
-			$st = userpoints_userpointsapi($params);
-			db_query("insert into {uc_up_award_log} (uid, oid, points) values(%d, %d, %d)",$curUserId, $order->order_id, $points);
-		}
-	}
-	
-	// Award referral points, if appropriate
-	if ($refUserId != 0 && ($award_to==0 || $award_to==2)) {
-		if ($total < $min) {
-			$points = 0;
-		}
-		else {
-			$points = intval(($total * $multiplier * $ref_mult));
-			$params = array (
-				'tid' => variable_get(USERPOINTS_AWARD_CATEGORY, 0),
-				'uid' => $refUserId,
-				'points' => $points,
-				'operation' => 'insert',
-				'description' => 'Purchase made by someone you referred, awarding points to referrer (Ubercart Order ID ' . $order->order_id . ')',
+        'moderate' => variable_get(USERPOINTS_AWARD_MODERATE, 0),
+      );
+      $st = userpoints_userpointsapi($params);
+      db_query("insert into {uc_up_award_log} (uid, oid, points) values(%d, %d, %d)",$curUserId, $order->order_id, $points);
+    }
+  }
+
+  // Award referral points, if appropriate
+  if ($refUserId != 0 && ($award_to==0 || $award_to==2)) {
+    if ($total < $min) {
+      $points = 0;
+    }
+    else {
+      $points = intval(($total * $multiplier * $ref_mult));
+      $params = array (
+        'tid' => variable_get(USERPOINTS_AWARD_CATEGORY, 0),
+        'uid' => $refUserId,
+        'points' => $points,
+        'operation' => 'insert',
+        'description' => 'Purchase made by someone you referred, awarding points to referrer (Ubercart Order ID ' . $order->order_id . ')',
 //				'entity_id' => $order->order_id,
 //				'entity_type' => 'Ubercart Transaction',
-				'moderate' => variable_get(USERPOINTS_REF_MODERATE, 0),
-			);
-			$st = userpoints_userpointsapi($params);
-			db_query("insert into {uc_up_award_log} (uid, oid, points) values(%d, %d, %d)",$curUserId, $order->order_id, $points);
-		}
-	}
-}	
+        'moderate' => variable_get(USERPOINTS_REF_MODERATE, 0),
+      );
+      $st = userpoints_userpointsapi($params);
+      db_query("insert into {uc_up_award_log} (uid, oid, points) values(%d, %d, %d)",$curUserId, $order->order_id, $points);
+    }
+  }
+}
