• ECSHOP 商品评论条件修改——购买过该商品且只能评价一次(购买多少次能评价多少次)


    下文转自http://bbs.ecshop.com/thread-1131529-1-1.html

    ECSHOP 商品评论条件修改,修改为购买过该商品多少次,就只能评价多少次。
    不需要修改数据库,原理简介:先在后台商店设置->基本->评论条件为只有购买过此商品的会员才能评价
    ECSHOP原有机制是只要购买过一次,就可以无限评价。
    这里老杨加入了简单判断,判断会员对此商品是否进行过评价,获取评价数,再获取此商品的购物次数。评价数不能大于或等于购物次数。
    老杨官网原帖:http://www.lyecs.com/article/w-41.html

    修改如下:

    打开comment.php
    找到:(注意,这文件有两处一样的,都要修改!)

     1     case COMMENT_BOUGHT :  
     2         if ($_SESSION['user_id'] > 0)  
     3         {  
     4             $sql = "SELECT o.order_id".  
     5                    " FROM " . $ecs->table('order_info'). " AS o, ".  
     6                    $ecs->table('order_goods') . " AS og ".  
     7                    " WHERE o.order_id = og.order_id".  
     8                    " AND o.user_id = '" . $_SESSION['user_id'] . "'".  
     9                    " AND og.goods_id = '" . $cmt->id . "'".  
    10                    " AND o.order_status = '" . OS_CONFIRMED . "' ".  
    11                    " AND (o.pay_status = '" . PS_PAYED . "' OR o.pay_status = '" . PS_PAYING . "') ".  
    12                    " AND (o.shipping_status = '" . SS_SHIPPED . "' OR o.shipping_status = '" . SS_RECEIVED . "') ".  
    13                    " LIMIT 1";  
    14              $tmp = $db->getOne($sql);  
    15              if (emptyempty($tmp))  
    16              {  
    17                 $result['error']   = 1;  
    18                 $result['message'] = $_LANG['comment_brought'];  
    19              }  
    20         }  
    View Code

    替换为

     1     case COMMENT_BOUGHT :  
     2         if ($_SESSION['user_id'] > 0)  
     3         {  
     4             $sql = "SELECT COUNT(o.order_id)".  
     5                    " FROM " . $ecs->table('order_info'). " AS o, ".  
     6                    $ecs->table('order_goods') . " AS og ".  
     7                    " WHERE o.order_id = og.order_id".  
     8                    " AND o.user_id = '" . $_SESSION['user_id'] . "'".  
     9                    " AND og.goods_id = '" . $cmt->id . "'".  
    10                    " AND (o.order_status = '" . OS_CONFIRMED . "' or o.order_status = '" . OS_SPLITED . "') ".  
    11                    " AND (o.pay_status = '" . PS_PAYED . "' OR o.pay_status = '" . PS_PAYING . "') ".  
    12                    " AND (o.shipping_status = '" . SS_SHIPPED . "' OR o.shipping_status = '" . SS_RECEIVED . "') ".  
    13                    " LIMIT 1";  
    14              $bought_count = $db->getOne($sql);  
    15              if (!$bought_count)  
    16              {  
    17                 $result['error']   = 1;  
    18                 $result['message'] = $_LANG['comment_brought'];  
    19              }else{  
    20                 $sql = "SELECT COUNT(comment_id) FROM " . $ecs->table('comment') .  
    21                     " WHERE user_id = '" . $_SESSION['user_id'] . "'".  
    22                     " AND id_value= '" . $cmt->id . "'".  
    23                     " LIMIT 1";  
    24                 $comment_count = $db->getOne($sql);  
    25                 if($comment_count >= $bought_count){  
    26                     $result['error']   = 1;  
    27                     $result['message'] = '您已对此商品进行过评价!您可以继续购买以便再次评论。';                                        
    28                 }  
    29              }  
    30         }  
    View Code
  • 相关阅读:
    WebClient, HttpClient, HttpWebRequest ,RestSharp之间的区别与抉择(几种Http请求方法)
    关于c#里面的httpclient的调用
    mvc项目架构分享系列之架构搭建初步 架构搭建初步
    关于在.NET中 DAL+IDAL+Model+BLL+Web
    三层架构(DAL/BLL/UI)和MVC设计模式的关系
    c#开发初学者之mvc及架构分层
    c#串口编程(转)
    【WPF】对话框/消息弹窗
    WPF如何不显示最大化,最小化的按钮
    信息学奥赛一本通(C++)在线评测系统——基础(一)C++语言——1103:陶陶摘苹果
  • 原文地址:https://www.cnblogs.com/iz100/p/3178673.html
Copyright © 2020-2023  润新知