欧美极品在线观看不卡|国产精品Va免费视频|国产国产人无码在线免费|亚洲精品无码九九九九九|亚洲国产综合精品久久久久|成人国产在线观看高清不卡|制服诱惑一区二区三区六区|国产一区二区精品高清在线观看

新聞中心

Ecshop教程:獲取某個商品的訂單信息或銷量

作者 / 無憂主機 時間 2015-12-08 13:40:45

很多人在php空間中建立了一個網(wǎng)站后,都會因為網(wǎng)站后期需要,想要查看單個某一商品的訂單信息或者是銷售量。類似網(wǎng)站后臺報表統(tǒng)計,有個這個的話,對于商品的銷量和訂單信息就有了一個很好的統(tǒng)計了。因此,要獲取ecshop某個商品的訂單信息或銷量,可以把以下這段代碼放到 ecshop程序文件的lib_main.php中: 1.統(tǒng)計某個下單商品的人數(shù)

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個人下單,數(shù)量是5 ,那返回結(jié)果是3 2.統(tǒng)計某個下單商品的銷量,
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個人下單,數(shù)量是5 ,那返回結(jié)果是5 3.統(tǒng)計某個商品商品訂單的詳細信息,在制作相應(yīng)ecshop商城模板時就可以用到這個數(shù)據(jù)
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); 
}
/*獲取某個商品有效訂單 銷量統(tǒng)計*/
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'; 
}
}
無憂主機相關(guān)文章推薦閱讀: ECSHOP如何手動清除緩存 ECSHOP測試數(shù)據(jù)通過SQL語句清除 ECSHOP教程:后臺管理顯示擴展分類

本文地址:http://www.gle-technology.com/ecshop/21083.html

1
1
1
1
1
1
1

客戶服務(wù)熱線

0791-8623-3537

在線客服