jQuery(function(t){if(t(".bodycommerce-minicart").prependTo(".shop-cart"),t(".post-type-archive-product").on("click",".quantity input",function(){return!1}),t(".archive").on("change input",".quantity .qty",function(){var a=t(this).parents(".product").find(".add_to_cart_button, .ajax_add_to_cart");a.data("quantity",t(this).val()),a.attr("href","?add-to-cart="+a.attr("data-product_id")+"&quantity="+t(this).val())}),t(".input-text.qty.text").bind("keyup mouseup",function(){var a=t(this).val();t(".product_quantity").val(a)}),"undefined"==typeof wc_add_to_cart_params)return!1;t(".ajax_add_to_cart").removeClass("add_to_cart_button"),t(document).on("click",".ajax_add_to_cart",function(a){a.preventDefault(),a.stopPropagation();var o=t(this),e=o.closest("form.cart").serializeArray();if(t(".db_atc_notify_txt").length){var r=t(".db_atc_notify_txt").val(),c=t(".db_atc_notify_txt_time").val(),i=t(".db_atc_notify_bg_color").val(),n=t(".db_atc_notify_text_color").val(),d=o.text();o.attr("style","color:"+n+" !important; background-color:"+i+" !important;"),o.text(r),o.addClass("active"),setTimeout(function(){o.text(d),o.removeClass("active"),o.removeAttr("style")},c)}o.closest(".et_pb_db_shop_loop").length>0&&(t(".et_pb_db_shop_loop").find(".woocommerce-notices-wrapper").removeClass("main"),t(".et_pb_db_shop_loop").find(".woocommerce-notices-wrapper").html(""),o.closest(".et_pb_db_shop_loop").find(".woocommerce-notices-wrapper").addClass("main"));var s=t(this).closest(".grouped_form"),l=t(this).closest(".variations_form");t(".ajaxerrors").remove();var p={},u=!0;(variations=l.find("select[name^=attribute]")).length||(variations=l.find("[name^=attribute]:checked")),variations.length||(variations=l.find("input[name^=attribute]"));var m=bc_add_to_cart_params.ajax_error_text;if(variations.each(function(){var a,o,e=t(this),r=e.attr("name"),c=e.val();e.removeClass("error"),0===c.length?(a=r.lastIndexOf("_"),o=r.substring(a+1),e.addClass("required error").before('

'+m+" "+o+"

"),u=!1):p[r]=c}),!u)return!1;if(!o.is(".ajax_add_to_cart"))return!0;if(o.removeClass("added"),o.addClass("loading"),t(this).parents(".variations_form")[0])var b=l.find("input[name=product_id]").val(),f=l.find("input[name=quantity]").val(),h={action:"bodycommerce_ajax_add_to_cart_woo",product_id:b,quantity:f,variation_id:l.find("input[name=variation_id]").val(),variation:p},v="yes";else if(t(this).parents(".grouped_form")[0]){var g=s.find("input[name=add-to-cart]").val(),y={};s.find(".woocommerce-grouped-product-list-item").each(function(){var a=t(this),o=a.attr("id"),e=a.find(".qty").val();y[o]=e});var h={action:"bodycommerce_ajax_add_to_cart_woo_bundle",product_id:g,quantity:"0",grouped_data:y},v="no"}else{var b=t(this).parent().find(".product_id").val();void 0===b&&(b=t(".et_pb_db_atc_0 .button").val()),void 0===b&&void 0!==t(this).attr("value")&&(b=t(this).attr("value")),t(this).hasClass("wc-bookings-booking-form-button")&&(b=t(this).parent().find(".wc-booking-product-id").val());var f=t(this).parent().find(".qty").val(),h={action:"bodycommerce_ajax_add_to_cart_woo_single",product_id:b,quantity:f},v="yes"}if(t.each(e,function(t,a){"add-to-cart"!=a.name&&(h[a.name]=a.value)}),h.hasOwnProperty("subscribe-to-action-input")&&"no"==h["subscribe-to-action-input"]&&(h["convert_to_sub_"+b]="0"),"yes"==v)return t("body").trigger("adding_to_cart",[o,h]),t.post(wc_add_to_cart_params.ajax_url,h,function(a){if(a){"string"==typeof a&&(a=JSON.parse(a));var e=window.location.toString();if(e=e.replace("add-to-cart","added-to-cart"),a.error&&a.product_url){t(".woocommerce-notices-wrapper.main").length>0?t(".woocommerce-notices-wrapper.main").html(a.error_message):t(".et_pb_db_notices").length>0&&t(".et_pb_db_notices").html('
'+a.error_message+"
"),o.removeClass("loading");return}if("yes"===wc_add_to_cart_params.cart_redirect_after_add){window.location=wc_add_to_cart_params.cart_url;return}o.removeClass("loading");var r=a.fragments;a.cart_hash,r&&t.each(r,function(a){t(a).addClass("updating")}),t(".shop_table.cart, .updating, .cart_totals").fadeTo("400","0.6").block({message:null,overlayCSS:{opacity:.6}}),o.addClass("added"),r&&t.each(r,function(a,o){"div.woocommerce-notices-wrapper.main"==a&&(t(".woocommerce-notices-wrapper.main").length>0?t(".woocommerce-notices-wrapper.main").html(o):t(".woocommerce-notices-wrapper").length>0?t(".woocommerce-notices-wrapper").html(o):t(".et_pb_db_notices").length>0&&t(".et_pb_db_notices").html('
'+o+"
")),t(a).replaceWith(o)}),t(".widget_shopping_cart, .updating").stop(!0).css("opacity","1").unblock(),t(".shop_table.cart").load(e+" .shop_table.cart:eq(0) > *",function(){t(".shop_table.cart").stop(!0).css("opacity","1").unblock(),t(document.body).trigger("cart_page_refreshed")}),t("#bodycommerce_added_to_cart_popup").addClass("active"),t(".cart_totals").load(e+" .cart_totals:eq(0) > *",function(){t(".cart_totals").stop(!0).css("opacity","1").unblock()}),t(document).trigger("bodycommerce_atc_completed")}}),!1;jQuery.ajax({url:ajax_object.ajax_url,data:h,type:"POST",dataType:"JSON",beforeSend:function(t){},success:function(a){if(void 0!==a.error&&!0==a.error)t(".woocommerce-notices-wrapper").length>0?t(".woocommerce-notices-wrapper").html(a.error_message):t(".et_pb_db_notices").length>0&&t(".et_pb_db_notices").html('
'+a.error_message+"
");else{var o=a.fragments;a.cart_hash,t(".shop_table.cart, .updating, .cart_totals").fadeTo("400","0.6").block({message:null,overlayCSS:{opacity:.6}}),o&&t.each(o,function(a,o){t(a).replaceWith(o)}),t(".widget_shopping_cart, .updating").stop(!0).css("opacity","1").unblock(),t(".shop_table.cart").load(this_page+" .shop_table.cart:eq(0) > *",function(){t(".shop_table.cart").stop(!0).css("opacity","1").unblock(),t(document.body).trigger("cart_page_refreshed")}),t("#bodycommerce_added_to_cart_popup").addClass("active"),t(".cart_totals").load(this_page+" .cart_totals:eq(0) > *",function(){t(".cart_totals").stop(!0).css("opacity","1").unblock()}),t(document).trigger("bodycommerce_atc_completed")}},error:function(t,a){console.log("error!")}})}),jQuery(document).on("divi_machine_modal_loaded",function(){console.log("modal loaded"),setTimeout(function(){console.log("modal loaded 2"),jQuery(".post-modal-cont .et_pb_db_atc button.single_add_to_cart_button.button").each(function(t,a){jQuery(this).addClass("ajax_add_to_cart")})},500)})});