网站增加购买过该商品的用户还购买了那些商品
2016-07-07 14:55 来源:www.chinab4c.com 作者:ecshop专家
网站增加购买过该商品的用户还购买了那些商品 |
回答:
看EC的商品页面代码。默认就有了 |
默认的那个 是哪个 啊 |
找默认模板 |
默认的就有 bought_goods.lbi 就是 |
这个在ecshop中其实自带这个功能,但是ecshop中的这个功能是根据订单商品order_goods 表来获取的数据,实际上只是获得了 购买这个商品的订单中的其他的商品 ,而不是购买这个商品的人还购买了哪些商品,对此我做了一些改进。 先看函数 在goods.php中添加function get_have_buys($goods_id); /* 购买过该商品的人还购买了 */ function get_have_buys($goods_id){ $sql = “select distinct(o.user_id) from “.$GLOBALS['ecs']->table(“order_goods”).” as og “. “left join “.$GLOBALS['ecs']->table(“order_info”).” as o on og.order_id=o.order_id “. ” where og.goods_id=’$goods_id’ and (o.order_status=1 or o.order_status=5)and o.user_id!=0″; //获得购买过该商品的人 ,这些用户不包括那些没有注册的人,否则得话就会有许多不真实的商品出现 $users = $GLOBALS['db']->getAll($sql); $ins = ”; foreach($users as $key=>$val){ $ins .= $val['user_id'].”,”; } $ins = rtrim($ins,’,'); if(empty($ins)){ return array(); } //这些人都购买了哪些东西 $sql = “select distinct(og.goods_id) from “.$GLOBALS['ecs']->table(“order_goods”).” as og “. “left join “.$GLOBALS['ecs']->table(“order_info”).” as o on og.order_id=o.order_id “. ” where o.user_id in ($ins) and (o.order_status=1 or o.order_status=5)”; $goods = $GLOBALS['db']->getAll($sql); $ins = ”; foreach($goods as $keys=>$val){ $ins.=$val['goods_id'].”,”; } $ins = rtrim($ins,’,'); if(empty($ins)){ return array(); } $sql = “select * from “.$GLOBALS['ecs']->table(“goods”).” where goods_id in ($ins) and is_on_sale = 1 AND is_alone_sale = 1 and is_delete=0 limit 10″; $res = $GLOBALS['db']->query($sql); $arr = array(); while ($row = $GLOBALS['db']->fetchRow($res)) { if ($row['promote_price'] > 0) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); } else { $promote_price = 0; } /* 处理商品水印图片 */ $watermark_img = ”; if ($promote_price != 0) { $watermark_img = “watermark_promote_small”; } elseif ($row['is_new'] != 0) { $watermark_img = “watermark_new_small”; } elseif ($row['is_best'] != 0) { $watermark_img = “watermark_best_small”; } elseif ($row['is_hot'] != 0) { $watermark_img = ‘watermark_hot_small’; } if ($watermark_img != ”) { $arr[$row['goods_id']]['watermark_img'] = $watermark_img; } $arr[$row['goods_id']]['goods_id'] = $row['goods_id']; if($display == ‘grid’) { $arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; } else { $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; } $arr[$row['goods_id']]['name'] = $row['goods_name']; $arr[$row['goods_id']]['goods_brief'] = $row['goods_brief']; $arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']); $arr[$row['goods_id']]['market_price'] = price_format($row['market_price']); $arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']); $arr[$row['goods_id']]['type'] = $row['goods_type']; $arr[$row['goods_id']]['promote_price'] = ($promote_price > 0) ? price_format($promote_price) : ”; $arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); $arr[$row['goods_id']]['url'] = build_uri(‘goods’, array(‘gid’=>$row['goods_id']), $row['goods_name']); } return $arr; } |
直接复制出来,多好。作者为一楼的,我只是复制出来了。。。。。。。 |
把我的复制出来干啥 还想推广下网站呢 |
最近更新
常用插件
- ecshop商品分类名称增加样
ecshop插件介绍:本插件可以方便在后台管理,为ecshop商品分类名称增加样...
- ecshop二次商品订购人信息
ecshop二次商品订购人信息填写插件,有时候给朋友送花,或者是送礼品的...
- ecshop分类批量扩展插件
ecshop分类批量扩展插件,这个插件是ecshop插件里面比较核心的插件。我们...
- ecshop二次开发详细页面生
插件介绍: ECSHOP系统,在很多时候,很多商品没有人购买,不但购买的人...
- ecshop2.7.1打印发货单插件
ecshop2.7.1打印发货单插件介绍:ecshop2.7.1和以前的ecshop版本不一样,ecs...
ecshop热门问答
ecshop热门资料
ecshop解救
ecshop奔驰S级
ecshophtm
ecshop日本
ecshop短信发送
ecshop按钮
ecshop支付方式类
ecshop救人
ecshop字问题
ecshop卡片
ecshop更改
ecshop老记
ecshop解锁来
ecshop小语种
ecshopQQ浏览器
mysql支持
ecshop次货
ecshopStrict
ecshop无图片
ecshop管理站
HDwiki模板
ecshop江山
ecshop商品页
ecshop死链接
ecshop画面
ecshop购买人数
ecshop显示分析
ecshopagency
ecshop户口
qq登录ecshop