!function(t){t(document).on("click",".wcmlim_ajax_add_to_cart",function(a){a.preventDefault();var o=t(this),e=o.data("quantity")||1,i=o.data("product_id"),r=o.data("product_sku"),c=o.data("product_price"),n=o.data("selected_location"),d=o.data("location_key"),l=o.data("location_qty"),u=o.data("location_termid"),s=o.data("location_sale_price"),p=o.data("location_regular_price");product_backorder=o.data("product_backorder"),is_redirect=o.data("isredirect"),redirect_url=o.data("cart-url"),l<=0&&1!==product_backorder&&t.ajax({type:"post",url:wc_add_to_cart_params.ajax_url,data:{action:"wcmlim_ajax_validation_manage_stock",product_id:i},beforeSend:function(t){o.removeClass("added").addClass("loading")},complete:function(t){o.addClass("added").removeClass("loading")},success:function(t){if("0"==t)return Swal.fire({icon:"error",text:"Product doesn't have a stock!"}),!0}});var f={action:"wcmlim_ajax_add_to_cart",product_id:i,product_sku:r,quantity:e,product_price:c,product_location:n,product_location_key:d,product_location_qty:l,product_location_termid:u,product_location_sale_price:s,product_location_regular_price:p};return t(document.body).trigger("adding_to_cart",[o,f]),t.ajax({type:"post",url:wc_add_to_cart_params.ajax_url,data:f,beforeSend:function(t){o.removeClass("added").addClass("loading")},complete:function(t){o.addClass("added").removeClass("loading")},success:function(a){if("4"==a)return Swal.fire({title:"Not Available!",text:`Available quantity is ${l} at location ${n}`,icon:"warning"}).then(()=>{window.location.href=window.location.href}),!1;if("1"==a?Swal.fire({title:"Cart Validation",text:"Your cart contains items from another location, do you want to update the cart",icon:"warning",showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:"Yes, Update Cart!"}).then(t=>{if(t.isConfirmed){let{ajaxurl:a}=multi_inventory;jQuery.ajax({url:a,type:"post",data:{action:"wcmlim_empty_cart_content"},success(t){Swal.fire({title:"Updated Cart!",text:"Your cart items has been updated, Please add the item again!",icon:"success"}).then(()=>{window.location.href=window.location.href})}})}}):"2"==a?Swal.fire({title:"Not Available!",text:"Item is not available at this location!",icon:"warning"}).then(()=>{window.location.href=window.location.href}):"3"==a&&Swal.fire({title:"Not Available!",text:"Please select any location!",icon:"warning"}).then(()=>{window.location.href=window.location.href}),a.error&&a.product_url){window.location=a.product_url;return}t(document.body).trigger("added_to_cart",[a.fragments,a.cart_hash,o]),"yes"==is_redirect&&(window.location=redirect_url)}}),!1})}(jQuery);