2026-02-05 17:08:59 +03:00

1 line
4.5 KiB
JavaScript

!function(o){"use strict";var e=function(){var e,n,c=0;e=fusion.getAdminbarHeight(),n=o(".fusion-header-wrapper").find("div"),c=0,n.each((function(){"fixed"===o(this).css("position")&&(c=o(this).height())})),o("html, body").stop(),setTimeout((function(){o("html, body").animate({scrollTop:o(".woocommerce-notices-wrapper").offset().top-e-c-10},500)}),10)};o("form.checkout").on("checkout_place_order",(function(){if(Boolean(fusionWooNoticesVars.login_required)&&!fusionWooNoticesVars.is_logged_in)return e(),!1})),o("form.checkout_coupon").on("submit",(function(e){const n=o(e.currentTarget);n.find("#coupon_code").length?n.find(".awb-coupon-error-wrapper").find(".coupon-error-notice").remove():(n.prepend('<div class="awb-coupon-error-wrapper"><span id="coupon_code"></span></div>'),n.find(".awb-coupon-error-wrapper").hide())})),o(document.body).on("checkout_error avada_checkout_error",(function(e,n){var c,r,t=0,i=0,s=0,a="undefined"!=typeof avadaWooCommerceVars?avadaWooCommerceVars.woocommerce_checkout_error:"";o(".fusion-woo-notices-tb .woocommerce-notices-wrapper").length&&("checkout_error"===e.type&&void 0!==n?((c=o(n.replace(/<li>/g,'<li class="avada-checkout-error">'))).find("li[data-id]").each((function(){o("#"+o(this).data("id")+"_field").addClass("woocommerce-invalid woocommerce-invalid-required-field")})),1<c.find("li").length&&c.find("li").each((function(){o(this)[0].hasAttribute("data-id")&&(s++,o(this).remove())})),0<s&&c.find("ul").append('<li class="avada-checkout-error">'+a+"</li>"),t=fusion.getAdminbarHeight(),r=o(".fusion-header-wrapper").find("div"),i=0,r.each((function(){"fixed"===o(this).css("position")&&(i=o(this).height())}))):(void 0===n&&(n=a),c=o('<ul class="woocommerce-error"><li class="avada-checkout-error">'+n+"</li><ul>")),c.find(".wc-block-components-notice-banner__summary").length?c.find(".wc-block-components-notice-banner__summary").wrapInner('<span class="wc-notices-text"></span>').prepend(fusionWooNoticesVars.error_icon):c.find(".wc-block-components-notice-banner__content").wrapInner('<span class="wc-notices-text"></span>').prepend(fusionWooNoticesVars.error_icon),o(".woocommerce-NoticeGroup-checkout, .woocommerce-error, .woocommerce-message").remove(),o(".fusion-woo-notices-tb .woocommerce-notices-wrapper").prepend(c[0].outerHTML),"checkout_error"===e.type&&(o("html, body").stop(),setTimeout((function(){o("html, body").animate({scrollTop:o(".fusion-woo-notices-tb .woocommerce-notices-wrapper").offset().top-t-i-10},500)}),10)))})).on("applied_coupon_in_checkout removed_coupon_in_checkout",(function(n,c){var r="applied_coupon_in_checkout"===n.type?"form.checkout_coupon":"form.woocommerce-checkout",t="success",i=o(".fusion-woo-notices-tb .woocommerce-notices-wrapper"),s="";i.empty(),o(r).children(".awb-coupon-error-wrapper").children(".coupon-error-notice").length?(t="error",s=o('<div class="wc-block-components-notice-banner is-error" role="alert"><div class="wc-block-components-notice-banner__content">'+o(r).children(".awb-coupon-error-wrapper").children(".coupon-error-notice").text()+"</div></div>")):(s=o(r).prev()).hasClass("is-info")&&(t="notice"),i.length&&s.length&&(s.find(".wc-block-components-notice-banner__summary").length?s.find(".wc-block-components-notice-banner__summary").wrapInner('<span class="wc-notices-text"></span>').prepend(fusionWooNoticesVars[t+"_icon"]):s.find(".wc-block-components-notice-banner__content").wrapInner('<span class="wc-notices-text"></span>').prepend(fusionWooNoticesVars[t+"_icon"]),i.prepend(s),e())})).on("applied_coupon removed_coupon",(function(e,n){var c=o(".fusion-woo-notices-tb .woocommerce-notices-wrapper"),r="success",t="";o(".avada-cart-actions .coupon").find(".coupon-error-notice").length?(r="error",t='<div class="wc-block-components-notice-banner is-error" role="alert"><div class="wc-block-components-notice-banner__content">'+o(".avada-cart-actions .coupon").find(".coupon-error-notice").text()+"</div></div>",c.append(t)):c.find(".is-info").length&&(r="notice"),c.length&&(c.find(".wc-block-components-notice-banner__summary").length?c.find(".wc-block-components-notice-banner__summary").wrapInner('<span class="wc-notices-text"></span>').prepend(fusionWooNoticesVars[r+"_icon"]):c.find(".wc-block-components-notice-banner__content").wrapInner('<span class="wc-notices-text"></span>').prepend(fusionWooNoticesVars[r+"_icon"]))})).on("updated_checkout payment_method_selected",(function(e,n){o(".fusion-woo-notices-tb .woocommerce-notices-wrapper").length&&o(".woocommerce-notices-wrapper").filter((function(){return 0===o(this).closest(".fusion-woo-notices-tb").length})).remove()}))}(jQuery);