[分享]Ecshop显示销量总数

2016-01-22PHP2155

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'];//某个商品的销售总数

  • 相关文章
  • 查看评论:(0)
【已经有0位大神发现了看法】

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

分享:

支付宝

微信