您好,UncleToo欢迎您!  为了更好的浏览本站,请使用高版本浏览器
RSS  Tag     设为首页 | 加入收藏
 您所在的位置:首页 > 开源项目

ecshop二次开发:在商品列表页显示重量、货号、购买数量

作者:  来源:互联网  日期:2013-11-24 10:14:19
收藏  评论:( 0 )  阅读:73

ecshop二次开发:在商品列表页显示重量、货号、购买数量

一、在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> 

二、在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'); 
}<SPAN style="BACKGROUND-COLOR: rgb(255,255,255); FONT-FAMILY: Arial, Helvetica, sans-serif"> </SPAN> 

三、在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']]['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'];

到此,商品列表页就可以显示重量、货号、购买数量了




除非特别声明,本站所有PHP教程及其他教程/文章均为原创、翻译或网友投稿,版权均归UncleToo中文网所有, 转载请注明作者及出处。
原文网址:http://www.uncletoo.com/html/openobj/694.html
读完这篇文章后,你是否有所收获? 分享是一种生活的信念!
  • 0
  • 0
我来说两句
更多>>网友评论