是一個使用jquery技術的特效,可以讓顧客在將商品加入購物車時,商品的圖片會由大變小動態的移至購物車中,增加顧客的網站購物體驗!!
使用方式:
一、在page_header.lbi中置入如下js代碼
<script type="text/javascript">
var Cart = {
id: 'ECS_CARTINFO',addProduct: function(cpid) {
//²K¥[°Ó«~
var ops = $(".goodsItem").find("[id=product_”+cpid+”]");
if(ops.length>0) {
var nps = ops.clone().css({"position":"absolute", "top": ops.offset().top, "left": ops.offset().left, "z-index": 999999999}).show();
nps.appendTo("body").animate({top:$("#ECS_CARTINFO").offset().top, left: $("#ECS_CARTINFO").offset().left, width: 50, height:50 }, {duration: 1000, callback: function(){}, complete: function(){ nps.remove() } });
}
var op = $(".imgInfo").find("img:first");
if(op.length>0) {
var np = op.clone().css({"position":"absolute", "top": op.offset().top, "left": op.offset().left, "z-index": 999999999}).show();
np.appendTo("body").animate({top:$("#ECS_CARTINFO").offset().top, left: $("#ECS_CARTINFO").offset().left, width: 50, height:50 }, {duration: 1000, callback: function(){}, complete: function(){ np.remove() } });
}
}
}$(function() {
$('[id^=iproduct_{$goods.goods_id}]').click(function() {
var cpid = this.id.replace('iproduct_{$goods.goods_id}','{$goods.goods_id}');
if($('#product_amount').length>0) {
if(n<1) { n=1; }
Cart.addProduct(cpid, n, 0);
}else{
Cart.addProduct(cpid, 1, 0);
}
return false;
});
});</script>
二、然後在對應的商品列表頁、商品詳情頁面、和搜索頁面、還有品牌頁面的goods.dwt文中修改代碼
<a href="javascript:addToCart({$goods.goods_id})"><img src="images/bnt_cat.gif" id='iproduct_{$goods.goods_id}' onclick="javascript:addToCart({$goods.goods_id})" /></a>
三、最後在goods_list.lbi中修改代碼
<a href="javascript:addToCart({$goods.goods_id})"><img src="images/bnt_cat.gif" id='iproduct_{$goods.goods_id}' onclick="javascript:addToCart({$goods.goods_id})" /></a>
發佈留言