Index: uc_upsell.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uc_upsell/uc_upsell.module,v
retrieving revision 1.7.2.15
diff -u -r1.7.2.15 uc_upsell.module
--- uc_upsell.module	18 Apr 2009 07:57:11 -0000	1.7.2.15
+++ uc_upsell.module	21 Apr 2009 17:57:30 -0000
@@ -732,7 +732,6 @@
 
 /**
  * Revert parts of upsell variable's root keys
- * TODO: Revisit, since I don't think this is being used yet.
  */
 function uc_upsell_reset_config($delkeys = array()) {
 
@@ -905,7 +904,7 @@
     $rel_count = count($related);
 
     // Get/add nids related to the cart
-    //$related = array_merge($related, uc_upsell_get_associate_nids($cart_nids, $vars['max'] - count($related)));
+    $related = array_merge($related, uc_upsell_get_associate_nids($cart_nids, $vars['max'] - count($related)));
 
     // if related count is greater than original...
     if (count($related) > $rel_count) {
@@ -936,7 +935,8 @@
     if (!empty($random_nids)) {
       $sources += 1;
     }
-    //drupal_set_message('USING: '.$config['global']['taxonomy']);
+
+    // Depending on our taxonomy settings, manipulate the array
     switch($config['global']['taxonomy']) {
       case 'ignore':
         $related = array_merge($related, $random_nids);
@@ -946,7 +946,6 @@
         $terms = taxonomy_node_get_terms($node);
         $node_tids = array();
 
-        //drupal_set_message('Terms: for nid  '.$nid .' are '.print_r($terms, true)); //You can see the array before use rsort()
         foreach ($terms AS $term) {
           //drupal_set_message('Term: '.$term->tid);
           $node_tids[] = $term->tid;
@@ -984,7 +983,7 @@
  * Find the associate nids
  */
 function uc_upsell_get_associate_nids($source, $max = 0, $filter = array()) {
-  // Process args (a bit more robust here, since developer's will likely use it)
+  // Process args (a bit more robust here, since developers will likely use it)
 
   // Ensure source an array
   if (!is_array($source) && (is_numeric($source) || (is_object($source) && $source->nid))) $source = array((is_numeric($source)) ? $source : $source->nid);
@@ -994,7 +993,6 @@
   if (!is_int($max) && is_numeric($max)) $max = abs(round($max));
   // If source or filter is not an array, or max is not an integer, exit function
   if (!is_array($source) || !is_array($filter) || !is_int($max)) {
-    //drupal_set_message('returning');
     return array();
   }
 
@@ -1004,24 +1002,14 @@
   foreach ($source as $nid) {
     if ((is_object($nid) && $nid->nid) || (is_array($nid) && $nid['nid'])) $nid = (is_object($nid)) ? $nid->nid : $nid['nid'];
 
-      // If we can get related nodes by taxonomy, let's do it.
-
     if (is_numeric($nid)) {
       $sought[] = $nid;
-
-
-      $ary = array();
-
-
-
       $config = uc_upsell_get_config();
-      $node = node_load(arg(1));
+      $node = node_load($nid);
       $terms = taxonomy_node_get_terms($node);
       $node_tids = array();
 
-      //drupal_set_message('Terms: for nid  '.$nid .' are '.print_r($terms, true)); //You can see the array before use rsort()
       foreach ($terms AS $term) {
-        //drupal_set_message('Term: '.$term->tid);
         $node_tids[] = $term->tid;
       }
 
@@ -1029,11 +1017,12 @@
       $allterms = cache_get('uc_upsell_terms');
       $intersect = array_intersect($node_tids, unserialize($allterms->data));
       $related = db_result(db_query("SELECT `related_products` FROM {uc_upsell_products} WHERE nid = %d", $nid));
-      $related_by_term = uc_upsell_nids_by_term($intersect, arg(1));
+      $related_by_term = uc_upsell_nids_by_term($intersect, $nid);
 
       // If we found an array of related products specified in the node form, let's initialize them.
       if ($related && is_array(unserialize($related))) $related = unserialize($related);
 
+      // If we can get related nodes by taxonomy, let's do it.
       switch($config['global']['taxonomy']) {
         case 'ignore':
           $ary = array_merge($ary, $related);
@@ -1061,7 +1050,6 @@
 
   // If max is valid, slice array to only show our configured maximum
   if ($max > 0) $ary = array_slice($ary, 0, $max);
-  //drupal_set_message('returning array '.print_r($ary, true));
   return $ary;
 
 }

