ecshop评价中评率好评率差评率【仿京东仿淘宝中差好评】

ECSHOP插件网提供的如下代码,实现仿京东仿淘宝中评、差评、好评功能。
1.打开goods.php文件中添加如下代码:
$sql = "SELECT * FROM " .$ecs->table('comment'). " WHERE comment_type = 0 AND status = 1 AND comment_rank != 0 AND id_value=$goods_id";
$comments = $db->getall($sql);
$count = count($comments);
$zhonghao = '';
$zhonghaoimg = '';
$hao = 0;
$zhong = 0;
$cha = 0;
$haol = '';
$zhongl = '';
$chal = '';
foreach ($comments as $value)
{
    if ($value['comment_rank'] == 1)
    {
        $cha = $cha+1;
    }
    if ($value['comment_rank'] == 2 or $value['comment_rank'] == 3 or $value['comment_rank'] == 4)
    {
        $zhong = $zhong+1;
    }
    if ($value['comment_rank'] == 5)
    {
        $hao = $hao+1;
    }
}
$smarty->assign('zhonghao', round($hao/$count*100,0));
$smarty->assign('count',    $count);
$smarty->assign('zhong',    round($zhong/$count*100,0));
$smarty->assign('cha',      round($cha/$count*100,0));
$smarty->assign('haol',     round($hao/$count*100/100*143,0)); 
$smarty->assign('zhongl',   round($zhong/$count*100/100*143,0)); 
$smarty->assign('chal',     round($cha/$count*100/100*143,0));
$smarty->assign('zhonghaoimg', round($hao*5/$count,0));
最后就是在模板中调用这些就可以了。
$smarty->assign('haol', round($hao/$count*100/100*143,0)); 这里面的143是那个评价进度条的总长度

本文原创地址:https://www.ecshop.cx/article-368.html
版权所有 © 转载时必须以链接形式注明出处!

觉得本文对您有用,想收藏下来!方法很简单:请点击-〉
我们一直坚持白天工作、晚上熬夜更新资源,付出了巨大的精力和时间,其中的辛酸难以言述。

文章评论

暂时还没有任何用户评论

发表 取消
实时购买动态 ×

menghuan会员 在 2018-11-30 购买了 ECSHOP启用伪静态功能配置文件【Apache、IIS、Lighttpd、LiteSpeed、Nginx】