取出购买记录、评价记录、订单页面取出商品图片
博客专区 > adbug 的博客 > 博客详情
取出购买记录、评价记录、订单页面取出商品图片
adbug 发表于2年前
取出购买记录、评价记录、订单页面取出商品图片
  • 发表于 2年前
  • 阅读 4
  • 收藏 0
  • 点赞 0
  • 评论 0

腾讯云 新注册用户 域名抢购1元起>>>   

调用购买评价:

$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)
{
$sql = 'SELECT IFNULL(SUM(g.goods_number), 0) ' .
'FROM ' . $GLOBALS['ecs']->table('order_info') . ' AS o, ' .
$GLOBALS['ecs']->table('order_goods') . ' AS g ' .
"WHERE o.order_id = g.order_id " . 
//"AND o.order_status = '" . OS_CONFIRMED . "' " .                 //订单状态
//"AND o.shipping_status " . db_create_in(array(SS_SHIPPED, SS_RECEIVED)) .  //配送状态
//" AND o.pay_status " . db_create_in(array(PS_PAYED, PS_PAYING)) .          //支付状态
" AND g.goods_id = '$goods_id'";
return $GLOBALS['db']->getOne($sql);
}
//取出评论总数
function get_comment_num($goods_id,$num1,$num2)
{
$sql= "select count(*) from ".$GLOBALS['ecs']->table('comment')." where id_value='".$goods_id."' AND status = 1 AND comment_rank>=".$num1." AND comment_rank<=".$num2."";
return $GLOBALS['db']->getOne($sql);

}

//根绝订单参数 取出商品图片

 $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}件


共有 人打赏支持
粉丝 7
博文 75
码字总数 198249
×
adbug
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: