跨境电商博客

Zen-cart产品页面显示星星评论代码

在zen-cart二次开发过程中,如何在zen-cart产品页面显示评论星星代码,博主摘录如下:
[php]
$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;
[/php]
将这段代码放到产品页面页面(/includes/templates/模板名称/templates/product_info.php)价格下面,样式可以自己调试,确定stars_0.gif的存在。

赞 (0) 打赏

评论 0

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏