升级说明
在列表页中显示克重、货号信息,用户可以在列表页直接输入要购买的数量。
升级方法
【1】themes\default\library\goods_list.lbi文件中找到<div class=”goodsItem”>,将改标签的内容修改如下:
<div class="goodsItem"> <ahref="{$goods.url}"><img src="{$goods.goods_thumb}"alt="{$goods.goods_name}" class="goodsimg"/></a><br /> <p><ahref="{$goods.url}"title="{$goods.name|escape:html}">{$goods.goods_name}</a></p> <!-- {if$show_marketprice} --> {$lang.market_prices}<fontclass="market_s">{$goods.market_price}</font><br /> <!-- {/if}--> <!--{if$goods.promote_price neq "" } --> {$lang.promote_price}<fontclass="shop_s">{$goods.promote_price}</font><br /> <!--{else}--> {$lang.shop_prices}<fontclass="shop_s">{$goods.shop_price}</font><br /> <!--{/if}--> {$lang.goods_sn}{$goods.goods_sn}<br /> {$lang.goods_weight}{$goods.goods_weight}{$lang.gram}<br /> {$lang.number}£º <inputname="number" type="text" id="{$goods.goods_id}"value="1" size="1" onblur="changePrice()"style="border:1px solid #ccc; "/> <ahref="javascript:collect({$goods.goods_id});"class="f6">{$lang.btn_collect}</a> | <ahref="javascript:addToCartFromCategory({$goods.goods_id})"class="f6">{$lang.btn_buy}</a> | <ahref="javascript:;" id="compareLink"onClick="Compare.add({$goods.goods_id},'{$goods.goods_name|escape:"html"}','{$goods.type}')"class="f6">{$lang.compare}</a> </div>
【2】js\common.js中增加一个函数:
/* *
* 将列表页的商品直接添加商品到购物车
*/
function addToCartFromCategory(goodsId, parentId)
{
var goods = new Object();
var spec_arr = new Array();
var fittings_arr = newArray();
var number = 1;
var quick = 0;
number =document.getElementById(goodsId).value;
quick = 1;
goods.quick = quick;
goods.spec = spec_arr;
goods.goods_id = goodsId;
goods.number = number;
goods.parent = (typeof(parentId) =="undefined") ? 0 : parseInt(parentId);
Ajax.call('flow.php?step=add_to_cart', 'goods=' + goods.toJSONString(),addToCartResponse, 'POST', 'JSON');
}
【3】category.php文件中:
将获得商品列表的sql查询由:
/* 获得商品列表 */ $sql = 'SELECT g.goods_id,g.goods_name, 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]') ASshop_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 ' . "ONmp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " . "WHERE $where$ext ORDER BY $sort $order";
改为:
$sql = 'SELECT g.goods_id, g.goods_name, g.goods_sn, g.goods_weight,g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_priceAS 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 ' . "ONmp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " . "WHERE $where$ext ORDER BY $sort $order";
同时,在本文件的:
$arr[$row['goods_id']]['name'] = $row['goods_name']; $arr[$row['goods_id']]['goods_brief'] = $row['goods_brief']; $arr[$row['goods_id']]['goods_style_name'] =add_style($row['goods_name'],$row['goods_name_style']); $arr[$row['goods_id']]['market_price'] = price_format($row['market_price']); $arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']); $arr[$row['goods_id']]['type'] = $row['goods_type']; $arr[$row['goods_id']]['promote_price'] = ($promote_price > 0) ?price_format($promote_price) : ''; $arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'],$row['goods_thumb'], true); $arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'],$row['goods_img']); $arr[$row['goods_id']]['url'] = build_uri('goods',array('gid'=>$row['goods_id']), $row['goods_name']);
之后追加以下两行内容:
$arr[$row['goods_id']]['goods_sn'] = $row['goods_sn']; $arr[$row['goods_id']]['goods_weight'] = $row['goods_weight'];