$(document).ready(function(){ //增加 $('.combosBox').on('click','.button5',function(e){ var pair= $(this).attr('type'), id = $(this).attr("sid"), num = $(this).parents(".productBox").find(".num-select").val(); $('.user-orderBox').removeClass('none'); if(id && num){ $.ajax({ url:'/activities/ajax/act4/ajax_set_cart.php', type:"POST", cache:false, async:true, data:{type:'add',pair:pair,Prod_Sell_ID:id,Amount:num}, error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, success:function(d){ $("#Act_Title_Box").html(d); for($i=1;$i<=4;$i++){ $("#SEL"+$i).html($("#ACT4_SEL"+$i).val()); $("#LES"+$i).html($("#ACT4_LES"+$i).val()); } } }); }else{ if(!id){ alert(_jsLang.請選擇尺寸與規格); }else if(!num){ alert(_jsLang.請選擇數量); } return false; } }); //減少 $(".redBox .orderSlideRGP,.greenBox .orderSlideRGP,.orangeBox .orderSlideRGP,.blueBox .orderSlideRGP").on('click','.delete',function(){ var _this = $(this).parents(".orderBox"); $.ajax({ url:'/activities/ajax/act4/ajax_set_cart.php', type:"POST", cache:false, async:true, data:{type:'del',pair:$(this).attr("pair"),ID:$(this).attr("del_id")}, error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, success:function(d){ $("#Act_Title_Box").html(d); for($i=1;$i<=4;$i++){ $("#SEL"+$i).html($("#ACT4_SEL"+$i).val()); $("#LES"+$i).html($("#ACT4_LES"+$i).val()); if($("#ACT4_SEL"+$i).val() == '0'){ setTimeout(function(){ _this.find('.pic-bg').text($(_this).attr('area')+_jsLang.尚未選購); },650) } } } }); }); //加入購物車 $("#Act_Title_Box").on('click','.Add_Tmp_To_Cart',function(){ $.ajax({ url:'/activities/ajax/ajax_add_to_cart.php', type:"POST", cache:false, async:true, data:{Act_Type:$(this).attr("act_type")}, dataType: 'json', error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, success:function(d){ switch(d.Status){ case "RET_SUCCESS": if(d.GA && typeof ga == 'function') { for(var key in d.GA) { Pro = JSON.parse(d.GA[key]); Sku = Pro['id']; ga('ec:addProduct',Pro); } ga('ec:setAction','add'); ga('send','event','購物車','加入購物車',Sku); } if(d.GA_conversion && typeof gtag == 'function') { gtag('event', 'add_to_cart', {'send_to':d.GA_conversion,'value':d.GA_values,'items':d.GA_items}); gtag('event', 'conversion', {'send_to':d.GA_conversion}); } if(d.FBQ){eval(d.FBQ)} if(d.GA4 && typeof gtag == 'function') { for(var key in d.GA4) { gtag("event","add_to_cart",{ "items":d.GA4 }); } } //LINE-Tag if(d.LINE_Tag_id){ _lt('send', 'cv', { type: 'AddToCart' },[d.LINE_Tag_id]); } window.dataLayer = window.dataLayer || []; var products = []; for(var i=0;i