ecshop如何在商品列表页上增加库存显示

ecshop网店在很多时候,需要将商品的库存在ecshop商品列表里面显示.

ecshop商品列表无非是首页,ecshop分类列表页,ecshop搜索页面和品牌显示页面.

下面将结合ecshop商品列表的程序,来演示ecshop商品列表中如何显示商品库存.

 

首先,要知道ecshop数据库表goods里的goods_number为库存字段,先检索出来就可以了。

$sql = 'SELECT g.goods_id, g.goods_name,g.goods_number, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' .
                "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, g.promote_price, g.goods_type, " .
                'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ' .
            'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
            'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' .
                "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " .
            "WHERE $where $ext ORDER BY $sort $order";

 

在这里将检索goods_number来在模板显示商品库存.将该字段放到数组中 $arr[$row['goods_id']]['goods_number']             = $row['goods_number'];

 

最后在 themes/default/library/goods_list.lbi 中使用 {$goods.goods_number} 来在模板显示商品库存.

 

你可能感兴趣的:(ecshop如何在商品列表页上增加库存显示)