PHP完全自学手册(珍藏版) 中文pdf扫描版下载
查看源码themmes/store/goodsinfo.html
发现其实有立即购买的按钮 但是这行代码被注释起来了。。
<!--<li class="btn_c1" title="{$lang.buy_now}"><a href="#"></a></li>-->
现在我们就用它 新增一个 立即购买的功能。
去掉该行注释 ,并修改为:
<li class="btn_c1 mar" title="立刻购买"><a href="javascript:buy_to_cart();"></a></li>
然后把以下的js代码添加到goodsinfo.html里面
function buy_to_cart()
{
if (goodsspec.getSpec() == null)
{
alert(lang.select_specs);
return;
}
var spec_id = goodsspec.getSpec().id;
var quantity = $("#quantity").val();
if (quantity == '')
{
alert(lang.input_quantity);
return;
}
if (parseInt(quantity) < 1)
{
alert(lang.invalid_quantity);
return;
}
buy_add_to_cart(spec_id, quantity);
}
function buy_add_to_cart(spec_id, quantity)
{
var url = SITE_URL + '/index.php?app=cart&act=add';
$.getJSON(url, {'spec_id':spec_id, 'quantity':quantity}, function(data){
if (data.done)
{
window.location.href = SITE_URL + '/index.php?app=cart';
}
else
{
alert(data.msg);
}
});
}
现在更新Ecmall的缓存 不出意外,立即购买的按钮出现了(我把加入收藏的给注释了)。
转载请注明:谷谷点程序 » Ecmall 商品直接购买功能