ECSHOP商品评论须购买过该商品且只能评价一次

商品评论修改为只有购买过该商品才能评论,且只能评论一次.

这里加入了简单判断,判断会员对此商品是否进行过评价,获取评价数,再获取此商品的购物次数。评价数不能大于或等于购物次数。

1.后台->商店设置->基本设置->商品评论的条件->仅购买过该商品用户

2.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 . "' 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 . "') ".
                                       " LIMIT 1";
                                 $tmp = $db->getOne($sql);
                                 if (empty($tmp))
                                 {
                                    $result['error']   = 1;
                                    $result['message'] = $_LANG['comment_brought'];
                                 }
                            }
                            else
                            {
                                $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 . "') ".
								   " LIMIT 1";
							$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 . "'".
								" LIMIT 1";
								$comment_count = $db->getOne($sql);
								if($comment_count >= $bought_count)
								{
									$result['error'] = 1;
									$result['message'] = '您已对此商品进行过评价!您可以继续购买以便再次评论。';
								}
							}
						}

效果如下:

转载自:http://www.lyecs.com/article/w-41.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值