濟南建網(wǎng)站知識,網(wǎng)站建設(shè)技術(shù)靈魂總結(jié)
Website news, Technical summary of soul
ecshop V2.7.3 商品屬性仿淘寶,以及庫存的聯(lián)動,這個功能在2.7.0的時候就有很多人呼吁官方開發(fā),可是不知道為什么,今天都到了2.7.3了,EC官方還是用原來那個很丑的樣子。沒辦法,求人不如求自己。濟南網(wǎng)站建設(shè)-濟南網(wǎng)站建設(shè)公司-濟南騰飛網(wǎng)絡今天就告訴大家實現(xiàn)這個功能的具體辦法。
效果如圖所示:
實現(xiàn)方法:
一、先下載test.gif文件
二、打開ecshop模版目錄的style.css文件,添加如下代碼:
.catt{
width:100%;
height:auto;
overflow:hidden;
padding-bottom:5px;
}
.catt a{
border: #7E7E7E 1px solid;
text-align: center;
background-color: #fff;
margin-left:5px;
margin-top:6px;
padding-left: 10px;
padding-right:10px;
display:block;
white-space: nowrap;
color:#000;
text-decoration:none;
float:left;
}
.catt a:hover {
border:#ED0036 2px solid;
margin: -1px;
margin-left:4px;
margin-top:5px;
}
.catt a:focus {
outline-style:none;
}
.catt .cattsel {
border:#ED0036 2px solid;
margin: -1px;
background: url("images/test.gif") no-repeat bottom right;
margin-left:4px;
margin-top:5px;
}
.catt .cattsel a:hover {
border: #ED0036 2px solid;
margin:-1px;
background: url("images/test.gif") no-repeat bottom right;
}
注:以上CSS可根據(jù)自己的情況修改。
三、打開echsop模版文件goods.dwt,找到:
<!-- {foreach from=$spec.values item=value key=key} -->
<label for="spec_value_{$value.id}">
<input type="radio" name="spec_{$spec_key}" value="{$value.id}" id="spec_value_{$value.id}" {if $key eq 0}checked{/if} onclick="changePrice()" />
{$value.label} [{if $value.price gt 0}{$lang.plus}{elseif $value.price lt 0}{$lang.minus}{/if} {$value.format_price|abs}]
</label>
<br />
<!-- {/foreach} -->
替換為:
<!-- {foreach from=$spec.values item=value key=key} -->
<a {if $key eq 0}class="cattsel"{/if} onclick="changeAtt(this,{$value.id},{$goods.goods_id})" href="javascript:;" name="{$value.id}" title="[{if $value.price gt 0}{$lang.plus}{elseif $value.price lt 0}{$lang.minus}{/if} {$value.format_price|abs}]">
{$value.label}
<input style="display:none" id="spec_value_{$value.id}" type="radio" name="spec_{$spec_key}" value="{$value.id}" {if $key eq 0} checked{/if} />
</a>
<!-- {/foreach} -->
四、在ECshop的模版文件里添加js文件:
function changeAtt(t,a,goods_id) {
t.lastChild.checked='checked';
for (var i = 0; i<t.parentNode.childNodes.length;i++) {
if (t.parentNode.childNodes[i].className == 'cattsel') {
t.parentNode.childNodes[i].className = '';
}
}
t.className = "cattsel";
var formBuy = document.forms['ECS_FORMBUY'];
spec_arr = getSelectedAttributes(formBuy);
Ajax.call('goods.php?act=get_products_info', 'id=' + spec_arr+ '&goods_id=' + goods_id, shows_number, 'GET', 'JSON');
changePrice();
}
function shows_number(result)
{
if(result.product_number !=undefined)
{
$('shows_number').innerHTML = result.product_number+'件';
}
else
{
$('shows_number').innerHTML = '未設(shè)置'
}
}
五、打開ecshop的goods.php ,大約在71行下添加如下代碼:
if (!empty($_REQUEST['act']) && $_REQUEST['act'] == 'get_products_info')
{
include('includes/cls_json.php');
$json = new JSON;
// $res = array('err_msg' => '', 'result' => '', 'qty' => 1);
$spce_id = $_GET['id'];
$goods_id = $_GET['goods_id'];
$row = get_products_info($goods_id,explode(",",$spce_id));
//$res = array('err_msg'=>$goods_id,'id'=>$spce_id);
die($json->encode($row));
}
好了!更新緩存,現(xiàn)在我們就實現(xiàn)了ecshop V2.7.3 商品屬性仿淘寶,以及庫存的聯(lián)動的功能了。
本文由濟南網(wǎng)站建設(shè)-濟南網(wǎng)站建設(shè)公司-濟南騰飛網(wǎng)絡整理發(fā)布。
轉(zhuǎn)載請注明。
公司地址:山東省濟南市東關(guān)大街中泰大廈 Copyright?2006-2020 news.jpx001.cn. 濟南網(wǎng)站設(shè)計我們值得信賴. All rights reserved .
7x24小時服務熱線:15069066861 網(wǎng)站建設(shè)博客