!function(i){null!=window.astra&&(astraSingleProductAjax={quick_view_enable:astra.shop_quick_view_enable||!1,ajax_add_to_cart_enable:astra.single_product_ajax_add_to_cart||!1,init:function(){this._bind()},_bind:function(){astraSingleProductAjax.ajax_add_to_cart_enable&&i(document).on("click","body.single-product .product:not(.product-type-external) button.single_add_to_cart_button",astraSingleProductAjax._processAjaxRequest),astraSingleProductAjax.quick_view_enable&&i(document.body).on("click","#ast-quick-view-content .product:not(.product-type-external) button.single_add_to_cart_button",astraSingleProductAjax._processAjaxRequest),i(document.body).on("added_to_cart",astraSingleProductAjax._updateButton)},_processAjaxRequest:function(t){t.preventDefault();var a=i(this).closest("form");if(!a[0].checkValidity())return a[0].reportValidity(),!1;var e=i(this),r=i(this).val()||"";i('input[name="variation_id"]').val();if(!e.hasClass("disabled")){e.removeClass("added"),e.addClass("loading");var n=i('input[name="quantity"]').val();if(i(".woocommerce-grouped-product-list-item").length){var d=i("input.qty");n=[];i.each(d,function(t,a){var e=i(this).attr("name");e=(e=e.replace("quantity[","")).replace("]",""),e=parseInt(e),i(this).val()&&(n[e]=i(this).val())})}var o=i("form.cart").serialize();i.ajax({url:astra.ajax_url,type:"POST",data:"action=astra_add_cart_single_product&add-to-cart="+r+"&"+o,success:function(t){i(document.body).trigger("wc_fragment_refresh"),i(document.body).trigger("added_to_cart",[t.fragments,t.cart_hash,e])}})}},_updateButton:function(t,a,e,r){r=void 0!==r&&r,i("button.single_add_to_cart_button").length&&(i(r).removeClass("loading"),i(r).addClass("added"),astra.is_cart||0!==i(r).parent().find(".added_to_cart").length||i(r).after(' '+astra.view_cart+""),i(document.body).trigger("wc_cart_button_updated",[r]))}},i(function(){astraSingleProductAjax.init()}))}(jQuery);