联系电话:0755-27515592
最新动态:

zencart教程

给ZenCart产品列表页和产品页面添加评论星星

点击数:13752015-07-30 10:06:54 来源: 外贸网站建设,深圳外贸网站建设,深圳网站建设,外贸商城网站制作-亿恩科技

新闻摘要: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_a

1,给ZenCart产品列表页面的产品添加评论小星星

打开文件includes\modules\你的模板\product_listing.php

 
  1. $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 />' : '') : '')  

 

#前面一行插入

 
  1. //显示评论星星start          
  2.         $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'] . "'";   
  3.         $count_stars = $db->Execute($count_stars_query);   
  4.         $starnum = round($count_stars->fields['aver']);   
  5.         $star = array("stars_1.gif","stars_2.gif","stars_3.gif","stars_4.gif","stars_5.gif");   
  6.       if($count_stars->fields['num']>=1){   
  7.       $reviews_display ='<div class="listreviews">< img src="includes/templates/你的模板/images/'. $star[$starnum-1] .'" /> ('.$count_stars->fields['num'].')</div>';   
  8.       }else{   
  9.       $reviews_display ='<div class="listreviews">< img src="includes/templates/你的模板/images/stars_0.gif" />(0)</div& gt;';   
  10.       }   
  11. //显示评论星星end   

 

#然后在ZenCart最开始的那段代码后天面添加$reviews_display就可以了:例如

 
  1. $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产品详细页面添加评论星星

 
  1. $count_stars_query = "select count(reviews_rating) as num, avg(reviews_rating) as aver  from " . TABLE_REVIEWS . " where products_id = '" . (int)$_GET['products_id'] . "'";   
  2.             $count_stars = $db->Execute($count_stars_query);   
  3.             $starnum = round($count_stars->fields['aver']);   
  4.             $star = array("stars_1.gif","stars_2.gif","stars_3.gif","stars_4.gif","stars_5.gif");   
  5.           if($count_stars->fields['num']>=1){   
  6.           $reviews_display ='<br />'.$count_stars-> fields['num'].' reviews<br><img src="includes/templates/模板 /images/'. $star[$starnum-1] .'" />';   
  7.           }else{   
  8.           $reviews_display ='<br />0 reviews<br><img src="includes/templates/模板/images/stars_0.gif" />';   
  9.           }   
  10.     echo $reviews_display;   

 

将这段代码放到ZenCart产品的价格下面,样式可以自己调试,确定stars_0.gif的存在。

【责任编辑:(Top) 返回页面顶端
贴心
全国7×24小时客服热线
安全
病毒杀除率高于99%
稳定
网站可用性高于99.9%
实力
服务68家上市企业及集团公司
亿恩科技手机站
关注亿恩科技微信

亿恩科技—企业信息化一站式服务专家


Copyright © 2008- 深圳市亿恩科技有限公司版权所有 粤ICP备15056041号

联系我们 | 常见问题 | 在线留言 | 支付方式 | 软件开发 | 我的观点 | 资质荣誉 | 服务流程