欢迎来到素材无忧网,按 + 收藏我们
登录 注册 退出 找回密码

ecshop商品属性库存仿淘宝属性库存联动显示的方法

时间: 2024-02-25 10:44 阅读: 作者:素材无忧网

ECSHOP有个货品功能,就是可以单独给商品的尺码、颜 设置库存。但是商品详情页却只能显示部库存。如果有个属 无货了,也不知道。本ECSHOP教程即可实现直接显示属 库存。是目前最完整最 的。
网上流传的免费教程有两个问题。
1、网上提供的教程无出现库存显示无效的情况,这是因为与jquery不兼容。
2、打开商品页面时,默认是选 中 个颜 的,但却显示总库存,造成误以为是 个颜 的库存。如果能打开页面就显示 个颜 库存就好了。
素材无忧提供本ECSHOP教程 解决这两个问题。
步:
下载选中小图标 test.gif ,保存路径:themes/default/images/test.gif 本教程最后面有下载。
第二步:
在模板样式中添加如下代码:如 themes/default/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文件 替换循环文件
查找:
 
替换为:
 {$value.label} 
第四步:
同样在本文件中 head区添加以下JS代码:
第五步:
打开goods.php ,大约在70行下添加一下代码:
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)); }
至此,已经可以显示属 库存了,下面解决打开页面默认显示总库存的问题。
仍然在 goods.dwt 文件中查找:
onload = function(){ changePrice(); fixpng(); try { onload_leftTime(); } catch (e) {} }
修改为:
onload = function(){ changePrice();
changeKucun();//这里是添加的
fixpng();
try { onload_leftTime(); }
catch (e) {} } //默认就显示个属性库存
function changeKucun() { var frm=document.forms['ECS_FORMBUY']; spec_arr = getSelectedAttributes(frm); Ajax.call('goods.php?act=get_products_info', 'id=' + spec_arr+ '&goods_id=' + goods_id, shows_number, 'GET', 'JSON'); }
OK了。
选中小图标下载:

版权声明: 本站资源均来自互联网或会员发布,如果侵犯了您的权益请与我们联系,我们将在24小时内删除!谢谢!

转载请注明: ecshop商品属性库存仿淘宝属性库存联动显示的方法

推荐文章
模板推荐