(function(t){t(document).on("click",".wcmlim_ajax_add_to_cart",function(a){a.preventDefault();var o=t(this),r=o.data("quantity")||1,e=o.data("product_id"),c=o.data("product_sku"),d=o.data("product_price"),i=o.data("selected_location"),n=o.data("location_key"),u=o.data("location_qty"),l=o.data("location_termid"),_=o.data("location_sale_price"),s=o.data("location_regular_price");product_backorder=o.data("product_backorder");is_redirect=o.data("isredirect");redirect_url=o.data("cart-url");if(u<=0&&product_backorder!==1){Swal.fire({icon:"error",text:"Product not available on selected location!"});return true}var p={action:"wcmlim_ajax_add_to_cart",product_id:e,product_sku:c,quantity:r,product_price:d,product_location:i,product_location_key:n,product_location_qty:u,product_location_termid:l,product_location_sale_price:_,product_location_regular_price:s};t(document.body).trigger("adding_to_cart",[o,p]);t.ajax({type:"post",url:wc_add_to_cart_params.ajax_url,data:p,beforeSend:function(t){o.removeClass("added").addClass("loading")},complete:function(t){o.addClass("added").removeClass("loading")},success:function(a){if(a=="1"){Swal.fire({title:"Cart Validation",text:"Your cart contains items from another location, do you want to update the cart",icon:"warning",showCancelButton:true,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:"Yes, Update Cart!"}).then(t=>{if(t.isConfirmed){const{ajaxurl:t}=multi_inventory;jQuery.ajax({url:t,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})}})}})}if(a.error&&a.product_url){window.location=a.product_url;return}else{t(document.body).trigger("added_to_cart",[a.fragments,a.cart_hash,o]);if(is_redirect=="yes"){window.location=redirect_url}}}});return false})})(jQuery);