ECSHOP 商品评论条件修改——购买过该商品且只能评价一次
发布:smiling 来源: PHP粉丝网 添加日期:2015-09-29 09:30:54 浏览: 评论:0
ECSHOP 商品评论条件修改,修改为购买过该商品多少次,就只能评价多少次,不需要修改数据库,原理简介:先在后台商店设置->基本->评论条件为只有购买过此商品的会员才能评价.
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'] = '您已对此商品进行过评价!您可以继续购买以便再次评论。'; //phpfensi.com
- }
- }
- }
Tags: ECSHOP商品评论 ECSHOP评价一次
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)