diff --git a/wp-content/themes/cosmopet/global-functions/multisite-functions.php b/wp-content/themes/cosmopet/global-functions/multisite-functions.php index 3aba101..e5ff1dd 100644 --- a/wp-content/themes/cosmopet/global-functions/multisite-functions.php +++ b/wp-content/themes/cosmopet/global-functions/multisite-functions.php @@ -87,112 +87,110 @@ if($site_env->site_mode == 'production' and $site_env->site_region == 'ae') { if (is_product() || is_shop() || is_cart()) { ?> - get_status() !== 'processing' && $order->get_status() !== 'completed')) return; + $order = wc_get_order($order_id); + if (!$order || ($order->get_status() !== 'processing' && $order->get_status() !== 'completed')) return; - $items = []; - foreach ($order->get_items() as $item) { - $product = $item->get_product(); - $items[] = [ - 'item_id' => $product->get_id(), - 'item_name' => $product->get_name(), - 'price' => $product->get_price(), - 'quantity' => $item->get_quantity() - ]; - } - ?> - - + cart ? WC()->cart->get_total('edit') : 0; + // 3. Событие AddPaymentInfo + if (is_checkout() && !is_wc_endpoint_url('order-received')) { + $currency = get_woocommerce_currency(); + $cart_total = WC()->cart ? WC()->cart->get_total('edit') : 0; ?> - - + } } /* Передача контрибуции со страницы "Спасибо" */ @@ -255,6 +253,7 @@ if($site_env->site_mode == 'production' and $site_env->site_region == 'ae') { } } +// TO_DO: удалить, если не нужно // Отключаем кэширование для страниц товаров add_action('template_redirect', function() { if (is_product()) { diff --git a/wp-content/themes/cosmopet/modules/footer/assets/js/footer.js b/wp-content/themes/cosmopet/modules/footer/assets/js/footer.js index 4e62de6..fb96dcf 100644 --- a/wp-content/themes/cosmopet/modules/footer/assets/js/footer.js +++ b/wp-content/themes/cosmopet/modules/footer/assets/js/footer.js @@ -7,34 +7,35 @@ // Флаг для предотвращения множественной обработки let isProcessing = false; + // TO_DO : вынести логику в модуль авторизации/регистрации // Login - $('.login_popup').on('click', function(e){ + $('.login_popup').on('click', function (e) { e.preventDefault(); $('.login_modal').addClass('active'); }); - $('.login_close').on('click', function(){ + $('.login_close').on('click', function () { $('.login_modal').removeClass('active'); $('.login_forms').removeClass('hide'); $('.login_success').addClass('hide'); $('.login_auth').addClass('hide'); isProcessing = false; // Сбрасываем флаг при закрытии }); - $('.login_back').on('click', function(){ - if($(this).is('.disabled')) { + $('.login_back').on('click', function () { + if ($(this).is('.disabled')) { return false; } $('.login_wrap .step').toggleClass('active'); }); - $('.login_input input').on('input keyup', function(){ + $('.login_input input').on('input keyup', function () { $('.login_input').removeClass('error'); }); - $('.js-get-code').on('click', function(){ + $('.js-get-code').on('click', function () { $('.login_input').removeClass('error'); - + var email = $('.js-input-email input').val(); $('.sended_email').text(email); - - if(email === '') { + + if (email === '') { $('.js-input-email').addClass('error'); $('.js-input-email .login_error').text(localeValue == 'en_US' ? 'Enter your email' : 'Укажите Email'); return false; @@ -43,9 +44,9 @@ $.ajax({ type: 'POST', url: '/wp-admin/admin-ajax.php', - data: {action: 'email_validate', email:email}, - success: function(data){ - if(data['status'] === 'error') { + data: { action: 'email_validate', email: email }, + success: function (data) { + if (data['status'] === 'error') { $('.js-input-email').addClass('error'); $('.js-input-email .login_error').text(data['text']); return false; @@ -57,63 +58,63 @@ }); } }); - $('.js-repeat-code').on('click', function(){ + $('.js-repeat-code').on('click', function () { $('.login_input').removeClass('error'); send_code(); }); - - function send_code(){ + + function send_code() { $('.login_timer').show(); $('.js-repeat-code').hide(); $('.login_back').addClass('disabled'); // Timer var seconds = 15; - var interval = setInterval(function() { - if (seconds > 0) { - seconds--; - $('.seconds').text(seconds); - } else { - clearInterval(interval); - $('.login_timer').hide(); - $('.js-repeat-code').show(); - $('.login_back').removeClass('disabled'); - $('.seconds').text(15); - } + var interval = setInterval(function () { + if (seconds > 0) { + seconds--; + $('.seconds').text(seconds); + } else { + clearInterval(interval); + $('.login_timer').hide(); + $('.js-repeat-code').show(); + $('.login_back').removeClass('disabled'); + $('.seconds').text(15); + } }, 1000); // Ajax отправка кода $.ajax({ type: 'POST', url: '/wp-admin/admin-ajax.php', - data: {action: 'send_code', email: $('.js-input-email input').val()} + data: { action: 'send_code', email: $('.js-input-email input').val() } }); } // Проверка кода и регистрация/авторизация - $('.js-input-code input').on('input keydown keyup propertychange paste cut copy change', function(){ + $('.js-input-code input').on('input keydown keyup propertychange paste cut copy change', function () { var val = $(this).val(); var email = $('.js-input-email input').val(); - if(val.length === 4 && !isProcessing) { + if (val.length === 4 && !isProcessing) { isProcessing = true; // Устанавливаем флаг, чтобы предотвратить повторную обработку $.ajax({ type: 'POST', url: '/wp-admin/admin-ajax.php', - data: {action: 'check_code', code: val, email: email}, - success: function(data){ + data: { action: 'check_code', code: val, email: email }, + success: function (data) { console.log('Server response:', data); // Отладка ответа сервера - if(data['status'] === 'success_reg') { + if (data['status'] === 'success_reg') { $('.login_forms').addClass('hide'); $('.login_success').removeClass('hide'); $('.login_auth').addClass('hide'); // Гарантируем, что login_auth скрыт if (typeof wc_checkout_params !== 'undefined') { location.reload(); } - } else if(data['status'] === 'success_auth' && !$('.login_success').is(':visible')) { + } else if (data['status'] === 'success_auth' && !$('.login_success').is(':visible')) { $('.login_forms').addClass('hide'); $('.login_auth').removeClass('hide'); $('.login_success').addClass('hide'); // Гарантируем, что login_success скрыт if (typeof wc_checkout_params !== 'undefined') { location.reload(); } - } else if(data['status'] === 'error') { + } else if (data['status'] === 'error') { $('.js-input-code').addClass('error'); $('.js-input-code .login_error').text(data['text']); isProcessing = false; // Сбрасываем флаг при ошибке @@ -124,17 +125,17 @@ isProcessing = false; // Сбрасываем флаг при неожиданном статусе } }, - error: function(xhr, status, error) { + error: function (xhr, status, error) { console.error('AJAX error:', error); // Отладка ошибок AJAX $('.js-input-code').addClass('error'); $('.js-input-code .login_error').text(localeValue == 'en_US' ? 'Server error' : 'Ошибка сервера'); isProcessing = false; // Сбрасываем флаг при ошибке AJAX } }); - } + } }); - - $('.email_link_form').on('submit', function(e){ + + $('.email_link_form').on('submit', function (e) { e.preventDefault(); $('.cabinet-card_linked-email .error').remove(); var data = $(this).serializeArray(); @@ -142,9 +143,9 @@ type: 'POST', url: '/wp-admin/admin-ajax.php', data: data, - success: function(data){ - if(data['error']) { - $('.cabinet-card_linked-email').append('