您现在的位置是:首页 > 教程 > ecshop商城教程ecshop商城教程
ecshop详细页面颜色尺码等规格和库存相连动的实现方法
王悟营2023-11-14 20:34:35ecshop商城教程已有人查阅
导读上一次我发表了改变商品详细页面属的样式但是在点击每个属的时候库存不根据属的改变而变化现在我们来完善它实现联动库存
上一次我发表了改变商品详细页面属的样式但是在点击每个属的时候库存不根据属的改变而变化现在我们来完善它实现联动库存
一、先下载test.gif文件
二、添加css文件找到style.css
三、添加循环文件,找到goods.dwt文件
找到:
一、先下载test.gif文件
二、添加css文件找到style.css
.catt{width: ;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;}
三、添加循环文件,找到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} -->
四、添加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.phpact=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 = '未设置'
}
}
五、添加php文件代码打开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));
}
OK更新一下缓存现在我们就实现了商品样式的改变和库存的联动
本文标签:
很赞哦! ()
相关文章
随机图文
-
ecshop一键删除版权的方法
ECSHOP代码号为了大众新手准备一键ecshop去版权插件方便新手版权修改。1、前台 title的 Powered by ecshop -
ecshop模板站内快讯怎么调用指定分类的文章
1、要求:在ECSHOP商城首页的“站内快讯”里只显示某个特定分类下的文章,例如只显示 类别ID为 5 ?的文章。 -
ecshop调用指定文章分类及调用指定商品分类商品的方法
ecshop数据调用分好几种, 种是js调用,利用后台生成js代码调用相应的产品,js调用的好处就是方便实用,一句话就可以完成调用,而且可以跨站调用,有利于推广。 -
ecshop广告图片增加alt=”广告关键字描述”的方法
1.在includes/lib_insert.php文件143和156行“a.ad_name,”后面增加“a.img_alt,”,在182行“src=’$src’”后面增加“alt=’$row[img_alt]‘”
留言与评论 (共有 条评论) |