<div class="content_topp"> <p>[ 仿淘宝 运费]方法:此方法没有调用数据库里那个,而是用JS实现的。
[ecshop 仿淘宝 运费]步骤:
1.goods.php(红色为增加的代码)
大概33行:
$goods_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
$smarty->assign('tc_goods_weight',get_goods_weight($goods_id));//tc:取得商品重量
$smarty->assign('regionname',get_region_name()); //tc:取得全国一级省市
然后在代码尾部加上两个函数:
//tc:取得全国一级城市信息
function get_region_name(){
$sql="SELECT * FROM ecs_region WHERE parent_id ='1';";
return $GLOBALS['db']->getAll($sql);
}
function get_goods_weight($goods_id){
$sql="select goods_weight from ecs_goods where goods_id = '$goods_id';";
$rs = $GLOBALS['db']->getAll($sql);
return $rs[0]['goods_weight'];
}
找到:
{$lang.goods_brand}
至 北京 : 快递 元
<div id="showList" style="position:absolute;border:2px solid #ccc; display:none;font-size:12px; padding:5px; background:#fff; width:260px; z-index:99999";>
{$tc_goods_weight.goods_weight}
{$region_names.region_name}
最后就是JS:
onload = function(){
changePrice();
fixpng();
initprice(); //tc:初始化运费信息
try { onload_leftTime(); }
catch (e) {}
}
<span style="color: #ff0000;">function initprice(){
var tc_goodsweight = Math.ceil($("hiddenprice").innerText);
tc_goodsweight == 0 ? 1 : tc_goodsweight;
if(tc_goodsweight =5 && tc_goodsweight=10 && tc_goodsweight=15 && tc_goodsweight |
|