Adding conditions to the template file of a view
To add a variable in template files you first need to create it in your template.php of the theme folder using template_preprocess_node function.



/**
* Implements template_preprocess_node.
*/
function theme_preprocess_node(&$variables){
  foreach($variables['field_taxonomy_field'] as $values){  //field_taxonomy_field is the machine name of the taxonomy term field of your content type.
    if($values['tid'] == $term_id){  //$term_id if the id of the term you want to compare. 
      $variables['compare_products'] = l("Compare Button", 'node/compare');
      //@todo your stuff here.
    }
  }
}



This will create a variable named $compare_products which you can use in the template file as a variable.

In node--product.tpl.php you can add &lt;?php print $compare_products; ?&gt; and the data from the variable will be shown whenever the variable is available.