$("body").on("click",".deleteproduct",function(){var t=$(this).attr("data-id");$.ajax({url:path+"cart/deleteProductFromCart",type:"POST",data:"productid="+t,success:function(t){location.reload()}})});

// $("body").on("click",".addTowishlist",function(){
// 	var t=$(this).attr("data-product");
// 	$.ajax({
// 		url:path+"cart/addProductInWishlist",
// 		type:"POST",
// 		data:"productid="+t,
// 		success:function(result){
// 			// location.reload();
// 			$('#wish-total').text(result.count);
// 			$('body').find('.wishmsg'+t).css('display','block');
// 			setTimeout(function(){
// 		        $('body').find('.wishmsg'+t).css('display','none');
// 		    }, 5000);
// 		}
// 	})
// });

$("body").on("click",".deleteproductWishlist",function(){var t=$(this).attr("data-id");$.ajax({url:path+"cart/deleteProductFromWishlist",type:"POST",data:"productid="+t,success:function(t){location.reload()}})});

$("body").on("click",".addTowishlist",function(){
	var t=$(this).attr("data-product");
	$.ajax({
		url:path+"front/addProductInWishlist",
		type:"POST",
		data:"productid="+t,
		success:function(result){
			// location.reload();
			$('#wish-total').text(result.count);
			$('body').find('.wishmsg'+t).css('display','block');
			$('button[data-product="'+t+'"]').removeClass('addTowishlist');
			$('button[data-product="'+t+'"]').addClass('deleteproductWishlist');
			$('button[data-product="'+t+'"]').find('i').removeClass('pe-7s-like');
			$('button[data-product="'+t+'"]').find('i').addClass('fa');
			$('button[data-product="'+t+'"]').find('i').addClass('fa-heart');
			setTimeout(function(){
		        $('body').find('.wishmsg'+t).css('display','none');
		    }, 5000);
		}
	})
});

$("body").on("click",".deleteproductWishlist",function(){
	var t=$(this).attr("data-product");
	$.ajax({
		url:path+"front/deleteProductFromWishlist",
		type:"POST",
		data:"productid="+t,
		success:function(result){
			$('#wish-total').text(result.count);
			// $(this).removeClass('deleteproductWishlist');
			// $(this).addClass('addTowishlist');
			$('button[data-product="'+t+'"]').addClass('addTowishlist');
			$('button[data-product="'+t+'"]').removeClass('deleteproductWishlist');
			$('button[data-product="'+t+'"]').find('i').addClass('pe-7s-like');
			$('button[data-product="'+t+'"]').find('i').removeClass('fa');
			$('button[data-product="'+t+'"]').find('i').removeClass('fa-heart');
			$('body').find('.deletewishmsg'+t).css('display','block');
		    $('body').find('.pro-'+t).remove();
			//location.reload();
			setTimeout(function(){
		        $('body').find('.deletewishmsg'+t).css('display','none');
		    }, 5000);
		}
	})
});

$("body").on("click",".addToCartP",function(){
	var productid = $(this).attr('data-pid');
	var pimg = $(this).attr('data-pimg');
	var price = $(this).attr('data-price');
	var pname = $(this).attr('data-pname');
    var type = '';
    var qty = 1;
    var size = '';
    var color = '';
    $.ajax({
        url: path+"cart/addProductInCart",
        type: 'POST',
        data: 'productid='+productid+'&qty='+qty+'&size='+size+'&color='+color+'&type='+type,
        success: function(data){
            if(data.found==0)
            {
                var cartDropdown = data.cartDropdown;
                var count = data.count;
                $("#cart-sidebar").html(cartDropdown);
                $("#cart-total").html(count);
                if(pimg!=''){
                	$('#pimageAtc').attr('src',pimg);
                }
                $('#pnameAtc').html(pname);
                $('#pPriceAtc').html('$'+price);
                // $('.sidebar-cart-active').addClass('inside');
                // $('.main-wrapper').addClass('overlay-active');
                $(".atc-success1").fadeIn();
                setTimeout(function() {
                    $(".atc-success1").hide().fadeOut();
                }, 5000);
            }else{
                alert(data.msg);
            }
        }
    });
});