调用购买评价:
$goods[$id]['num'] = get_buy_sum($row['goods_id']);//购买
$goods[$id]['pingjia'] = get_comment_num($row['goods_id'],1,5);//评价
$goods_list[$key]['goods_thumb'] = $val["goods_thumb"];//取出商品图片
php页面方法:
//ecshop实现销售多少件的功能
function get_buy_sum($goods_id)}
//根绝订单参数 取出商品图片
$goods_list = order_goods($order_id);
foreach ($goods_list AS $key => $value)
{
$goods_list[$key]['market_price'] = price_format($value['market_price'], false);
$goods_list[$key]['goods_price'] = price_format($value['goods_price'], false);
//通过订单循环取出ID,通过循环ID获取商品图片
$goods_list[$key]['subtotal'] = price_format($value['subtotal'], false);
$arr = get_img($value['goods_id']);
foreach($arr as $k=>$val)
{
$goods_list[$key]['goods_thumb'] = $val["goods_thumb"];
}
}
function get_img($gid)
{
$sql="select goods_thumb from " . $GLOBALS['ecs']->table('goods') . " where goods_id=".$gid;
$res=$GLOBALS['db']->getAll($sql);
return $res;
}
PHP页面调取:
1.如果是在单品页面调用:$smarty->assign('buy_num',get_buy_sum($goods_id));
2.如果是取出多个商品,因为要传ID给方法,所以要跟随数据库循环取出:
while($row = $GLOBALS['db']->fetchRow($result)){
$catelist[$row['goods_id']]['num'] = get_buy_sum($row['goods_id']);//循环取出购买记录
}
DWT页面展示:
1.单品调用:已 售 出:{$buy_num}件
2.循环调用:已 售 出:{$goods.num}件