Ecshop模板网
首页 > ecshop教程 > ecshop经验分享 > ecshop购买了某商品才能评价且只能评价一次
文章详情

ecshop购买了某商品才能评价且只能评价一次

ecshop模板网 / 2014-09-01

ECSHOP 购买条件优化-购买过几件该商品,就只能评价几次

ECSHOP原有机制是只要购买过一次,就可以无限评价。
我们则需要判断会员对此商品是否进行过评价,获取评价数,再获取此商品的购物次数,评价数不能大于或等于购物次数。

第一步:先在后台商店设置->基本->评论条件为只有购买过此商品的会员才能评价
第二步:

打开comment.php
找到:如下代码(PS您会找到两处,都要替换)
case COMMENT_BOUGHT :
if ($_SESSION['user_id'] > 0)
{
$sql = "SELECT o.order_id".
" FROM " . $ecs->table('order_info'). " AS o, ".
$ecs->table('order_goods') . " AS og ".
" WHERE o.order_id = og.order_id".
" AND o.user_id = '" . $_SESSION['user_id'] . "'".
" AND og.goods_id = '" . $cmt->id . "'".
" AND o.order_status = '" . OS_CONFIRMED . "' ".
" AND (o.pay_status = '" . PS_PAYED . "' OR o.pay_status = '" . PS_PAYING . "') ".
" AND (o.shipping_status = '" . SS_SHIPPED . "' OR o.shipping_status = '" . SS_RECEIVED . "') ".
" LIMIT 1";
$tmp = $db->getOne($sql);
if (emptyempty($tmp))
{
$result['error']   = 1;
$result['message'] = $_LANG['comment_brought'];
}
}


替换为:

case COMMENT_BOUGHT :
if ($_SESSION['user_id'] > 0)
{
$sql = "SELECT COUNT(o.order_id)".
" FROM " . $ecs->table('order_info'). " AS o, ".
$ecs->table('order_goods') . " AS og ".
" WHERE o.order_id = og.order_id".
" AND o.user_id = '" . $_SESSION['user_id'] . "'".
" AND og.goods_id = '" . $cmt->id . "'".
" AND (o.order_status = '" . OS_CONFIRMED . "' or o.order_status = '" . OS_SPLITED . "') ".
" AND (o.pay_status = '" . PS_PAYED . "' OR o.pay_status = '" . PS_PAYING . "') ".
" AND (o.shipping_status = '" . SS_SHIPPED . "' OR o.shipping_status = '" . SS_RECEIVED . "') ";
$bought_count = $db->getOne($sql);
if (!$bought_count)
{
$result['error']   = 1;
$result['message'] = $_LANG['comment_brought'];
}else{
$sql = "SELECT COUNT(comment_id) FROM " . $ecs->table('comment') .
" WHERE user_id = '" . $_SESSION['user_id'] . "'".
" AND id_value= '" . $cmt->id . "'";
$comment_count = $db->getOne($sql);
if($comment_count >= $bought_count){
$result['error']   = 1;
$result['message'] = '您已对此商品进行过评价!您可以继续购买以便再次评论。';
}
}
}

下一篇: 如何在ecshop文章中调用友情链接列表 上一篇: ecshop后台修改评论时间的方法
 用户评论(共 0 条评论)
  • 暂时还没有任何用户评论
用户名: 匿名用户 E-mail:
当前心情:
评论内容:
验证码: captcha
返回顶部 返回首页
 
QQ在线咨询
售前电话热线
#
售前QQ客服