ecshop 在确认收货时新增加商品评价并送消费积分功能

来源:互联网 发布:开个淘宝店需要电脑吗 编辑:程序博客网 时间:2024/03/29 07:50

根据项目的需要,鼓励用户购买商品之后对商品做出评价,特加用户点击确认收货时,跳转到商品评介功能.

为了防止用户点击用户确认之后没有评价,因此在订单信息表(tb_order_info)中加一字段”is_comment”判断是否已经评价过.如果没有评价就会显示评价商品



主要代码是user.php中,大概在1333行中修改确认收货,并加上下面两个动作



/* 确认收货 */elseif ($action == 'affirm_received'){    include_once(ROOT_PATH . 'includes/lib_transaction.php');    $order_id = isset($_GET['order_id']) ? intval($_GET['order_id']) : 0;    if (affirm_received($order_id, $user_id))    {        //ecs_header("Location: user.php?act=order_list\n");        ecs_header("Location: user.php?act=order_comment&order_id=$order_id\n");        exit;    }    else    {        $err->show($_LANG['order_list_lnk'], 'user.php?act=order_list');    }}//用户确认收货评论elseif($action=="order_comment"){$order_id = isset($_GET['order_id']) ? intval($_GET['order_id']) : 0;include_once(ROOT_PATH . 'includes/lib_order.php');$order_info=order_info($order_id);if($order_info['is_comment']){   ecs_header("Location: user.php?act=order_list\n");       exit;}    /* 订单商品 */    $goods_list = order_goods($order_id);    $smarty->assign('order_id',$order_id);    $smarty->assign('goods_list',$goods_list);    $smarty->display('order_comment.dwt');}//保存用户评价elseif($action=="save_comment"){include_once(ROOT_PATH . 'includes/lib_order.php');    /* 评论是否需要审核 */    $status = 1 - $GLOBALS['_CFG']['comment_check'];    $user_id =$_SESSION['user_id'];    $email = $_SESSION['email'];    $user_name = $_SESSION['user_name'] ;    $email = htmlspecialchars($email);    $user_name = htmlspecialchars($user_name);    $goods_list=$_POST['goods'];      foreach ($goods_list as $key=>$val) {    /* 保存评论内容 */    $sql = "INSERT INTO " .$GLOBALS['ecs']->table('comment') .           "(comment_type, id_value, email, user_name, content, comment_rank, add_time, ip_address, status, parent_id, user_id) VALUES " .           "('0', '" .$val['goods_id']. "', '$email', '$user_name', '" .$val['content']."', '".$val['comment_rank']."', ".gmtime().", '".real_ip()."', '$status', '0', '$user_id')";     $result = $GLOBALS['db']->query($sql);      }            $order_info=order_info($_REQUEST['order_id']);    if(!$order_info['is_comment'])    {        //修改订单的信息        update_order($_REQUEST['order_id'],array('is_comment'=>1));        $pay_point=$order_info['money_paid']-$order_info['shipping_fee'];     //送积分    if($pay_point)    {     log_account_change($user_id,0,0,0,$pay_point,'用户评论订单'.$order_info['order_sn'].'赠送消费积分');    }       }    clear_cache_files('comments_list.lbi');   ecs_header("Location: user.php?act=order_list\n");    //print_r($_POST);    exit;}

如果有技术问题:请加QQ群 231552899 一起讨论

另外还修改一个dwt文件,点击可下载模板页。