Ecshop模板开发(十二):商品详情页超值大礼包优惠活动

2017-04-10 by sinat_37390744

1、html代码

{if $package_goods_list} <h2>超值礼包</h2> {foreach from=$package_goods_list item=goods_list} <h4>{$goods_list.act_name}</h4> {foreach from=$goods_list.goods_list item=package} <p>{$package.goods_name}&nbsp;&nbsp;&nbsp;*{$package.goods_number}</p> {/foreach} <p>原价:<del>{$goods_list.subtotal}</del>&nbsp;&nbsp;&nbsp;礼包价:{$goods_list.package_price}&nbsp;&nbsp;&nbsp;节省:{$goods_list.saving}</p> <p> <a href="" onclick="addPackageToCart({$goods_list.act_id})">立即购买</a> </p> {/foreach} {/if}

2、js代码

function addPackageToCart(package_id) { var package_info= new Object(); var number = 1; package_info.package_id=package_id; package_info.number = number; $.post( 'flow.php?step=add_package_to_cart', {'package_info':JSON.stringify(package_info)}, function (result) { if (result.error > 0) { if (result.error == 2) { if (confirm(result.message)) { location.href = "user.php?act=add_booking&id=" + result.goods_id; } } else { alert(result.message); } } else { var cartInfo = document.getElementById('ECS_CARTINFO'); var cart_url = 'flow.php?step=cart'; if (cartInfo) { cartInfo.innerHTML = result.content; } if (result.one_step_buy == '1') { location.href = cart_url; } else { switch(result.confirm_type) { case '1' : if (confirm(result.message)) location.href = cart_url; break; case '2' : if (!confirm(result.message)) location.href = cart_url; break; case '3' : location.href = cart_url; break; default : break; } } } }, 'json' ); }

第七城市

栏目导航(关闭)