ECSHOP商品属性库存关联仿淘宝商品详细页
效果如下:
实现方法,修改goods.dwt如下:
{$value.label}
在显示详细信息合适的地方加
(库存:{$goods.goods_number} {$goods.measure_unit})
这是动态加载库存的地方
选择打钩这个样式论坛有人发过 也不是很难 我不在详细贴出
在goods.dwt加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 = '未设置'}}
打开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));}
通过以上操作便可实现仿淘宝颜色尺码选择功能
赞 (0)