| 
       
	1,给ZenCart产品列表页面的产品添加评论小星星 
	打开文件includes\modules\你的模板\product_listing.php 
	
		  
	
		- 
			$lc_text .= '' . (zen_get_show_product_switch($listing->fields['products_id'], 'ALWAYS_FREE_SHIPPING_IMAGE_SWITCH') ? (zen_get_product_is_always_free_shipping($listing->fields['products_id']) ? TEXT_PRODUCT_FREE_SHIPPING_ICON . '<br />' : '') : '')  
 
	 
 
	  
	#前面一行插入 
	
		  
	
		- 
			//显示评论星星start          
 
		- 
			        $count_stars_query = "select count(reviews_rating) as num, avg(reviews_rating) as aver  from " . TABLE_REVIEWS . " where products_id = '" . (int)$listing->fields['products_id'] . "'";   
 
		- 
			        $count_stars = $db->Execute($count_stars_query);   
 
		- 
			        $starnum = round($count_stars->fields['aver']);   
 
		- 
			        $star = array("stars_1.gif","stars_2.gif","stars_3.gif","stars_4.gif","stars_5.gif");   
 
		- 
			      if($count_stars->fields['num']>=1){   
 
		- 
			      $reviews_display ='<div class="listreviews"><img src="includes/templates/你的模板/images/'. $star[$starnum-1] .'" />('.$count_stars->fields['num'].')</div>';   
 
		- 
			      }else{   
 
		- 
			      $reviews_display ='<div class="listreviews"><img src="includes/templates/你的模板/images/stars_0.gif" />(0)</div>';   
 
		- 
			      }   
 
		- 
			//显示评论星星end   
 
	 
 
	  
	#然后在ZenCart最开始的那段代码后天面添加$reviews_display就可以了:例如 
	
		  
	
		- 
			$lc_text .= '' . (zen_get_show_product_switch($listing->fields['products_id'], 'ALWAYS_FREE_SHIPPING_IMAGE_SWITCH') ? (zen_get_product_is_always_free_shipping($listing->fields['products_id']) ? TEXT_PRODUCT_FREE_SHIPPING_ICON . '<br />' : '') : '') .'<br />'.$reviews_display;  
 
	 
 
	  
	这样,如果在前台页面显示位置不对,自己可以将$reviews_display位置稍作调试。(确认你的图片文件夹下有stars_0.gif这张图片哦) 
	  
	2,在ZenCart产品详细页面添加评论星星 
	
		  
	
		- 
			$count_stars_query = "select count(reviews_rating) as num, avg(reviews_rating) as aver  from " . TABLE_REVIEWS . " where products_id = '" . (int)$_GET['products_id'] . "'";   
 
		- 
			            $count_stars = $db->Execute($count_stars_query);   
 
		- 
			            $starnum = round($count_stars->fields['aver']);   
 
		- 
			            $star = array("stars_1.gif","stars_2.gif","stars_3.gif","stars_4.gif","stars_5.gif");   
 
		- 
			          if($count_stars->fields['num']>=1){   
 
		- 
			          $reviews_display ='<br />'.$count_stars->fields['num'].' reviews<br><img src="includes/templates/模板/images/'. $star[$starnum-1] .'" />';   
 
		- 
			          }else{   
 
		- 
			          $reviews_display ='<br />0 reviews<br><img src="includes/templates/模板/images/stars_0.gif" />';   
 
		- 
			          }   
 
		- 
			    echo $reviews_display;   
 
	 
 
	  
	将这段代码放到ZenCart产品的价格下面,样式可以自己调试,确定stars_0.gif的存在。 
      
      (责任编辑:最模板) |