jQuery(document).ready((function(a){a("body").on("submit","form.cart",(function(t){const r=a(this).parents(".type-product");if(r.hasClass("product-type-external")||r.hasClass("product-type-grouped"))return;t.preventDefault();const e=a(this),o=e.find(".single_add_to_cart_button");let d=e.serialize();d+="&action=flatsome_ajax_add_to_cart",o.val()&&(d+="&add-to-cart="+o.val()),o.addClass("loading"),a(document.body).trigger("adding_to_cart",[o,d]),a.ajax({url:window.flatsomeVars.ajaxurl,data:d,method:"POST",success:function(t){if(!t)return;const{product_url:r,notices:e,fragments:d,cart_hash:c,error:n=""}=t;if("undefined"==typeof wc_add_to_cart_params||"yes"!==wc_add_to_cart_params.cart_redirect_after_add)if(n&&r)window.location=r;else{if(o.removeClass("loading"),e.indexOf("error")>0)return jQuery.fn.magnificPopup&&jQuery.magnificPopup.close(),void a(".woocommerce-notices-wrapper").append(e);a(document.body).trigger("added_to_cart",[d,c,o])}else window.location=wc_add_to_cart_params.cart_url}})}))}));