$(document).ready(function(){
//增加
$('article > .combosBox ').on('click','.button1',function(e){
var id = $(this).attr("sid");
var num = $(this).parents(".productBox").find(".num-select").val();
if(id && num){
$.ajax({
url:'/gl/activities/ajax/act2/ajax_set_cart.php',
type:"POST",
cache:false,
async:true,
data:{type:'add',Prod_Sell_ID:id,Amount:num},
error:function(d){
alert(_jsLang.網路連線過慢網頁請重新整理);
},
success:function(d){
$("#Act_Title_Box").html(d);
}
});
}else{
if(!id){
alert(_jsLang.請選擇尺寸與規格);
}else if(!num){
alert(_jsLang.請選擇數量);
}
return false;
}
});
//減少
$(".user-list6 .orderSlide").on('click','.delete',function(){
$.ajax({
url:'/gl/activities/ajax/act2/ajax_set_cart.php',
type:"POST",
cache:false,
async:true,
data:{type:'del',ID:$(this).attr("del_id")},
error:function(d){
alert(_jsLang.網路連線過慢網頁請重新整理);
},
success:function(d){
$("#Act_Title_Box").html(d);
}
});
});
//加入購物車
$("#Act_Title_Box").on('click','.Add_Tmp_To_Cart',function(){
$.ajax({
url:'/gl/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(_jsLang.網路連線過慢網頁請重新整理);
},
success:function(d){
switch(d.Status){
case "RET_SUCCESS":
if (d.GA && typeof ga == 'function') {
for (var key in d.GA) {
ga('ec:addProduct', d.GA[key]);
}
ga('ec:setAction', 'add');
ga('send','event','購物車','addtocart',d.GA_event);
}
if(d.GA_conversion && typeof gtag == 'function')
{
gtag('event', 'conversion', {'send_to':d.GA_conversion});
}
if(d.FBQ)
{
eval(d.FBQ)
}
if(d.GA4 && typeof gtag == 'function')
{
gtag("event","add_to_cart",d.GA4);
}
if(d.Criteo && typeof window.criteo_q == 'object')
{
var deviceType = /iPad/.test(navigator.userAgent) ? "t" : /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(navigator.userAgent) ? "m" : "d";
window.criteo_q.push({event: "setAccount", account: d.Criteo_Account});
if(d.email)
{
window.criteo_q.push({event: "setEmail", email: d.email, hash_method: "sha256"});
}
window.criteo_q.push({event: "setSiteType", type: deviceType});
window.criteo_q.push({event: "setZipcode", zipcode: d.Zip});
window.criteo_q.push({event: "addToCart", item:d.Criteo});
}
alert(_jsLang.加入購物車成功);
window.location.reload();
break;
case "RET_NO_MEMBER_NO":
alert(_jsLang.欲購買紅利兌換商品請先登入會員並完成會員認證);
break;
case "RET_RBONUS_OUT":
alert(_jsLang.紅利不足);
break;
case "RET_ERROR":
alert(_jsLang.資料庫忙線中);
break;
case "RET_PROD_ERROR":
alert(_jsLang.商品已下架);
break;
case "RET_NO_PROD":
alert(_jsLang.請選擇商品);
break;
case "RET_STOCK_ERROR":
alert(_jsLang.商品庫存不足);
break;
case "RET_LIMIT_ERROR":
alert(_jsLang.數量超過限購量)
break;
case "RET_PROD_IN_ONESHOPPAGE_ERROR":
alert(_jsLang.此商品於一頁式購物推廣中+','+_jsLang.暫無法加入購物車);
break;
default:
alert(_jsLang.資料庫忙線中);
break;
};
}
});
});
});