获取ecshop某个商品的订单信息或销量
2016-09-07 22:02 来源:www.chinab4c.com 作者:ecshop专家
获取ecshop某个商品的订单信息或销量,把以下代码放到 lib_main.php 1.统计某个下单商品的人数 function get_goods_ordernum($goods_id){ $sql = "select count(goods_number) from " . $GLOBALS['ecs']->table('order_goods') . " AS g ,".$GLOBALS['ecs']->table('order_info') . " AS o WHERE o.order_id=g.order_id and g.goods_id = " . $goods_id . " and o.order_status in(1,5) " ;//o.order_status=1 表示确认了的订单才算 return $GLOBALS['db']->getAll($sql); } 注意:如果有3个人下单,数量是5 ,那返回结果是3 2.统计某个下单商品的销量, function get_goods_ordernum($goods_id){ $sql = "select sum(goods_number) from " . $GLOBALS['ecs']->table('order_goods') . " AS g ,".$GLOBALS['ecs']->table('order_info') . " AS o WHERE o.order_id=g.order_id and g.goods_id = " . $goods_id . " and o.order_status in(1,5) " ;//o.order_status=1 表示确认了的订单才算 return $GLOBALS['db']->getAll($sql); } 注意:如果有3个人下单,数量是5 ,那返回结果是5 3.统计某个商品商品订单的详细信息 function get_goods_ordernum($goods_id){ $sql = "select * from " . $GLOBALS['ecs']->table('order_goods') . " AS g ,".$GLOBALS['ecs']->table('order_info') . " AS o WHERE o.order_id=g.order_id and g.goods_id = " . $goods_id . " and o.order_status in(1,5) " ;//o.order_status=1 表示确认了的订单才算 return $GLOBALS['db']->getAll($sql); } order_status in(1,5) 1表示去人订单,5表示已分单 完整php代码 /*获取有效订单信息*/ function sales_goods_order($goods_id){ $sql = "select * from " . $GLOBALS['ecs']->table('order_goods') . " AS g ,".$GLOBALS['ecs']->table('order_info') . " AS o WHERE o.order_id=g.order_id and g.goods_id = " . $goods_id . " and o.order_status in(1,5) " ;//o.order_status=1 1表示确认订单,5已分单 return $GLOBALS['db']->getAll($sql); } /*获取某个商品有效订单 销量统计*/ function sales_goods_number($goods_id){ $arr = sales_goods_order($goods_id); //return array_sum($arr['goods_number']); foreach($arr as $k=>$v){ $val[] = $v['goods_number']; } $count = array_sum($val); if(!empty($count)){ return $count; }else{ return '0'; } } (责任编辑:chinab4c) |
最近更新
常用插件
- ecshop2.7.1邮件发送插件
ecshop2.7.1邮件发送插件:该插件主要的开发思想是源于ecshop短信发送系统...
- ecshop二次开发商品购买增
图片1香...
- ecshop2.7.2生成虚拟订单2.
以前我们开发过ecshop下的虚拟订单,就是客户在访问的时候,会自动生...
- ecshop没登陆情况下订单查
ecshop没登陆情况下订单查询插件,主要是针对ecshop在没有登陆的情况下...
- ecshop最小购买数量控制插
ecshop最小购买数量控制插件,这个插件主要是为我们提供一个十分方便...
ecshop热门问答
ecshop热门资料
ecshop出色网购
ecshop谷歌输入
ecshop饰你所爱
ecshop出现
ecshop歌曲
ecshop遨游
ecshop题外
ecshop新闻页面首页进不了
ecshop毛病
最新评论
ecshop底版
ecshomysqlrepair
ecshop二次
ecshopgoogle地图
ecshop广告图片
ecshop手续费
ecshopFLASHAD
ecshop降价
ecshop新产品
ecshop图片轮播
ecshop旗号
ecshop其他
ecshop呼叫中心
ecshop无法同步
ecshop分类
ecshop外派订单
ecshop竞争对手
ecshop图片库
ecshop订餐
ecshopGGAD