لطفا ابتدا اقدام به تسویه یا حذف محصول از سبد خرید خود شوید','info')}
var arr=new Array();let compare=(id)=>{let item=document.getElementById("compare_"+id);if(item.checked==true){if(arr.length===4){document.getElementById("compare_"+id).checked=false;alert("شما تنها چهار مورد را میتوانید انتخاب کنید");}
if(arr.length<4){let product=$("#compare_"+id).val();arr.push(product);if(arr.length===1){$("#btnCompare").attr("href","https://shop.es.co.ir/compare/"+arr[0]);}else if(arr.length===2){$("#btnCompare").attr("href","https://shop.es.co.ir/compare/"+arr[0]+"-"+arr[1]);}else if(arr.length===3){$("#btnCompare").attr("href","https://shop.es.co.ir/compare/"+arr[0]+"-"+arr[1]+"-"+arr[2]);}else if(arr.length===4){$("#btnCompare").attr("href","https://shop.es.co.ir/compare/"+arr[0]+"-"+arr[1]+"-"+arr[2]+"-"+arr[3]);}}}else{let index=arr.indexOf($("#compare_"+id).val());if(index>=0){arr.splice(index,1);let product=$("#compare_"+id).val();if(arr.length===1){$("#btnCompare").attr("href","https://shop.es.co.ir/compare/"+arr[0]);}else if(arr.length===2){$("#btnCompare").attr("href","https://shop.es.co.ir/compare/"+arr[0]+"-"+arr[1]);}else if(arr.length===3){$("#btnCompare").attr("href","https://shop.es.co.ir/compare/"+arr[0]+"-"+arr[1]+"-"+arr[2]);}else if(arr.length===4){$("#btnCompare").attr("href","https://shop.es.co.ir/compare/"+arr[0]+"-"+arr[1]+"-"+arr[2]+"-"+arr[3]);}else{$("#btnCompare").removeAttr("href");}}}}