“在ECSHOP首页显示商品库存的方法”, 下面是修改方法
1、
打开 /includes/lib_goods.php 文件(建议使用editplus)
找到下面代码(大概在287行左右)
//取出所有符合条件的商品数据,并将结果存入对应的推荐类型数组中
$sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' .
"IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ".
修改为
//取出所有符合条件的商品数据,并将结果存入对应的推荐类型数组中
$sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' .
"IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, g.goods_number,".
2、
接着,继续向下找到
if (in_array($row['goods_id'], $type_array['best']))
在它上面增加一行代码
$goods[$idx]['goods_number'] = $row['goods_number'];
yzzmf.com-->
3、然后再修改模板文件 /themes/模板文件夹/library/recommend_hot.lbi ,/themes/模板文件夹/library/recommend_new.lbi , /themes/模板文件夹/library/recommend_best.lbi
在
<font class="f1">
<!-- {if $goods.promote_price neq ""} -->
{$goods.promote_price}
<!-- {else}-->
{$goods.shop_price}
<!--{/if}-->
</font>
下面增加代码
<br>
<!-- {if $goods.goods_number eq 0} -->
<strong>{$lang.goods_number}</strong>
<font color='red'>{$lang.stock_up}</font>
<!-- {else} -->
<strong>{$lang.goods_number}</strong>
{$goods.goods_number} {$goods.measure_unit}
<!-- {/if} -->
3、最后一步记得去ECSHOP后台,清除一下缓存