[分享]Ecshop显示销量总数

2016-01-22PHP4351

function getGoodsTotalById($id){

   $sql = "SELECT COUNT(*) AS total_order, SUM(g.goods_number) AS total_goods " .

            "FROM " . $GLOBALS['ecs']->table('order_info') . " AS o, " .

                $GLOBALS['ecs']->table('order_goods') . " AS g " .

            " WHERE o.order_id = g.order_id " .

            " AND g.goods_id = $id" .

            " AND (order_status = '" . OS_CONFIRMED . "' OR order_status = '" . OS_UNCONFIRMED . "' OR order_status = '5')";

    $res = $GLOBALS['db']->getRow($sql);

    return $res;

}


$goods[$idx]['zhekou_price'] = round(($row['promote_price']/$row['shop_price'])*100)/10+"";//获取商品是几折



$totals=getGoodsTotalById($row['goods_id']);

$goods[$idx]['total_order'] = $totals['total_order'];//某个商品的订单总数,或者是用多少个人购买的这个商品

$goods[$idx]['total_goods'] = $totals['total_goods'];//某个商品的销售总数

关闭

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开微信扫一扫,即可进行扫码打赏哦

支付宝

微信