您现在的位置是:首页 > 教程 > ecshop商城教程ecshop商城教程
ecshop商品评论增加评论权限购买多少次评论多少次
听蓉2024-01-01 21:57:00ecshop商城教程已有人查阅
导读ecshop商品评论条件修改,修改为购买过该商品多少次,就只能评价多少次。不需要修改数据库,原理简介
ecshop商品评论条件修改,修改为购买过该商品多少次,就只能评价多少次。不需要修改数据库,原理简介:先在后台商店设置->基本->评论条件为只有购买过此商品的会员才能评价
ecshop原有机制是只要购买过一次,就可以 评价。
这里加入了简单判断,判断会员对此商品是否进行过评价,获取评价数,再获取此商品的购物次数。评价数不能大于或等于购物次数。
修改如下:
打开comment.php
找到:(注意,这文件有两处一样的,都要修改!)
ecshop原有机制是只要购买过一次,就可以 评价。
这里加入了简单判断,判断会员对此商品是否进行过评价,获取评价数,再获取此商品的购物次数。评价数不能大于或等于购物次数。
修改如下:
打开comment.php
找到:(注意,这文件有两处一样的,都要修改!)
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前台显示的页面的版权在下面几个地方修改:(本人不支持你去掉别人的版权,只做研究之用)1.meta标签中的Generator:includes目录内cls_template.php,里面有一段 -
ecshop商品详情页怎么显示供货商信息
ECSHOP供应商插件,ECSHOP供货商插件供货商入驻商城插件ECSHOP供应商入驻如何在ecshop商品详情页面显示该商品的供货商? -
ecshop商品详情页怎么增加自定义title标题
在ECSHOP后台自定义每个商品详情页的TITLE, 该如何来实现呢?(听说这样会对SEO更有利)下面就来讲一讲具体的修改方法: -
ecshop商品详情页商品描述上传中文名称图片无法显示处理方法
在后台上传商品图片的时候,如果你选择一个中文名称的图片,那么上传后会产生乱码,导致图片显示不出来。
留言与评论 (共有 条评论) |