Файловый менеджер - Редактировать - /home/harasnat/www/labour/wp-content/themes/woostify/assets/js/woocommerce/ajax-single-add-to-cart.min.js
Назад
"use strict";function woostifyAjaxSingleHandleError(t){"function"==typeof eventCartSidebarClose&&eventCartSidebarClose(),t&&t.classList&&t.classList.remove("loading"),document.documentElement.classList.remove("quick-view-open")}function woostifyAjaxSingleUpdateFragments(t){if(woostify_woocommerce_general.shipping_threshold.enabled_shipping_threshold&&woostify_woocommerce_general.shipping_threshold.enabled_shipping_threshold_effect){var e=document.querySelectorAll(".free-shipping-progress-bar"),r=0;e.length&&(r=parseInt(e[0].getAttribute("data-progress")))}fetch(wc_cart_fragments_params.wc_ajax_url.toString().replace("%%endpoint%%","get_refreshed_fragments"),{method:"POST"}).then(function(t){return t.json()}).then(function(t){void 0!==t.fragments&&Object.entries(t.fragments).forEach(function([t,e]){let r=document.querySelectorAll(t);r.length&&r.forEach(function(t){t.insertAdjacentHTML("afterend",e),t.remove()})})}).finally(function(){woostifyAjaxSingleHandleError(t),progressBarConfetti(e,r),jQuery(document.body).trigger("added_to_cart")})}function woostifyAjaxSingleAddToCartButton(){var t=document.querySelectorAll(".single_add_to_cart_button");t.length&&t.forEach(function(t){t.onclick=function(e){var r=t.closest("form.cart");if(!r||"POST"!==r.method.toUpperCase()||t.classList.contains("disabled"))return;e.preventDefault();let n=r.querySelector("input.qty"),o=r.querySelector("input.variation_id");null==n&&(n=r.querySelector('input[name="quantity"]'));let a=!!n&&Number(n.value.trim()),i=!!o&&Number(o.value.trim());if(!a||isNaN(a)||a<=0){alert(woostify_woocommerce_general.qty_warning);return}var c=t.value;try{var u=document.querySelector("div.cart-sidebar-content"),l=0;if(u.querySelectorAll(".woocommerce-mini-cart-item").forEach(function(t,e){if((t.querySelector("a.remove_from_cart_button").getAttribute("data-product_id")||0)==c){let r=t.querySelector("input.qty");null==r&&(r=t.querySelector('input[name="quantity"]')),l=!!r&&Number(r.value.trim())}}),i){l=0;let d=u.querySelector('input[data-variation_id="'+i+'"]');d&&(l=Number(d.value.trim()))}var s=parseInt(n.getAttribute("max")),f=l+a;if(s&&(l>=s||f>s)){alert(woostify_woocommerce_general.qty_max_warning);return}}catch(m){console.warn(m)}var p=new FormData(r);p.append("add-to-cart",r.querySelector("[name=add-to-cart]").value),p.append("ajax_nonce",woostify_woocommerce_general.ajax_nonce),t.classList.add("loading"),"function"==typeof eventCartSidebarOpen&&eventCartSidebarOpen(),"function"==typeof closeAll&&closeAll(),jQuery(document.body).on("added_to_cart",function(){"function"==typeof cartSidebarOpen&&cartSidebarOpen()}),document.documentElement.classList.add("mini-cart-updating"),fetch(wc_add_to_cart_params.wc_ajax_url.toString().replace("%%endpoint%%","woostify_single_add_to_cart"),{method:"POST",body:p}).then(function(t){if(t){200==t.status&&"function"==typeof cartSidebarOpen&&cartSidebarOpen();var e=t.json();if(e.error&&e.product_url||e.error&&e.product_url){window.location=e.product_url;return}if("yes"===wc_add_to_cart_params.cart_redirect_after_add){window.location=wc_add_to_cart_params.cart_url;return}return e}}).then(function(e){document.documentElement.classList.remove("mini-cart-updating"),woostifyAjaxSingleUpdateFragments(t),t.getAttribute("data-checkout_url")&&(window.location=t.getAttribute("data-checkout_url"))}).catch(function(){document.documentElement.classList.remove("mini-cart-updating"),woostifyAjaxSingleHandleError(t)})}})}function fixElementProErrorAddtoCart(){"undefined"!=typeof elementorFrontend&&"3.9.2"==(elementorFrontend.config.version||0)&&elementorFrontend.elements.$body.off("added_to_cart.elementor-woocommerce-product-add-to-cart")}document.addEventListener("DOMContentLoaded",function(){woostifyAjaxSingleAddToCartButton(),setTimeout(function(){fixElementProErrorAddtoCart()},200)});
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Генерация страницы: 0.01 |
proxy
|
phpinfo
|
Настройка