!function(a){"use strict";var e,r=function(){e||(e=!0,a(document).on("submit","form.cart:not(.auction_form)",(function(e){if(reyParams.single_ajax_add_to_cart&&("undefined"==typeof wc_add_to_cart_params||"yes"!==wc_add_to_cart_params.cart_redirect_after_add)){var r=a(this),o=a(".single_add_to_cart_button:not(.disabled)",r);if(!o.parents("div.product").hasClass("product-type-external"))if(e.preventDefault(),void 0!==reyParams.ajaxurl&&void 0!==reyParams.ajax_nonce){var t=r.serialize()||"";t+="&action=reycore_ajax_add_to_cart",o.val()&&(t+="&add-to-cart="+o.val()),t=rey.hooks.applyFilters("reycore/woocommerce/addtocart_data",t),a(document.body).trigger("adding_to_cart",[o,t]),a.ajax({type:"POST",url:reyParams.wc_ajax_url.toString().replace("%%endpoint%%","reycore_ajax_add_to_cart"),dataType:"json",data:t,beforeSend:function(e){a(".woocommerce-error",r).remove(),o.removeClass("added").addClass("loading")},success:function(e){if(e)if(void 0===e.success||!1!==e.success){var t=window.location.toString();if(t=t.replace("add-to-cart","added-to-cart"),e.error&&e.product_url)window.location=e.product_url;else if("undefined"==typeof wc_add_to_cart_params||"yes"!==wc_add_to_cart_params.cart_redirect_after_add)if("checkout"!==reyParams.after_add_to_cart){o.removeClass("loading");var d=e.fragments;d&&a.each(d,(function(e){a(e).addClass("updating")})),d&&a.each(d,(function(e,r){a(e).replaceWith(r)})),void 0!==e.notices&&""!==e.notices&&e.notices.indexOf("error")>0?(r.prepend(e.notices),o.addClass("not-added")):(o.addClass("added"),a(document.body).trigger("added_to_cart",[d,e.cart_hash,o])),a(document).trigger("reycore/woocommerce/after_added_to_cart",[e])}else window.location=reyParams.checkout_url;else window.location=wc_add_to_cart_params.cart_url}else console.warn(e.data)},error:function(){console.warn("Ajax add to cart error!")}})}else console.warn("Ajax url undefined")}})))};document.addEventListener("rey-DOMContentLoaded",(function(a){r()})),rey.hooks.addAction("ajax_variation_popup/after_open",(function(){r()})),rey.hooks.addAction("after_quickview",(function(a){r()}))}(jQuery);