Task 6879 | правки переводов в англ версии checkout

pull/36/head
parent b1c16bb1ea
commit 3dfad90868
  1. 43
      wp-content/themes/cosmopet/global-functions/multilang-functions.php
  2. 174
      wp-content/themes/cosmopet/modules/shop/components/checkout/assets/js/script.js
  3. 30
      wp-content/themes/cosmopet/modules/shop/module-controller.php
  4. 11
      wp-content/themes/cosmopet/woocommerce/cart/cart-shipping.php
  5. 10
      wp-content/themes/cosmopet/woocommerce/checkout/form-coupon.php
  6. 6
      wp-content/themes/cosmopet/woocommerce/checkout/review-order.php

@ -1723,4 +1723,47 @@ add_action('init', function () {
pll_register_string('Подписка не найдена или не принадлежит вам.', 'Подписка не найдена или не принадлежит вам.', 'profile-sub-single');
pll_register_string('Адрес доставки', 'Адрес доставки', 'profile-sub-single');
pll_register_string('Город', 'Город', 'profile-sub-single');
pll_register_string('contact_recipient', 'Контакты получателя', 'Checkout');
pll_register_string('logout', 'Выйти', 'Checkout');
pll_register_string('login', 'Войти', 'Checkout');
pll_register_string('shipping_title', 'Доставка', 'Checkout');
pll_register_string('pickup_point', 'Пункт выдачи', 'Checkout');
pll_register_string('choose_pickup_point', 'Выберите пункт выдачи', 'Checkout');
pll_register_string('delivery_address', 'Адрес доставки', 'Checkout');
pll_register_string('choose_delivery_address', 'Выберите адрес доставки', 'Checkout');
pll_register_string('delivery_comment', 'Комментарий для доставки', 'Checkout');
pll_register_string('your_order', 'Ваш заказ', 'Checkout');
pll_register_string('coupon_code', 'Код купона', 'Checkout');
pll_register_string('deliver_here', 'Доставить сюда', 'Checkout');
pll_register_string('address', 'Адрес', 'Checkout');
pll_register_string('start_typing_address', 'Начните вводить ваш адрес', 'Checkout');
pll_register_string('apartment', 'Квартира', 'Checkout');
pll_register_string('floor', 'Этаж', 'Checkout');
pll_register_string('entrance', 'Подъезд', 'Checkout');
pll_register_string('intercom', 'Домофон', 'Checkout');
pll_register_string('intercom code', 'Код домофона', 'Checkout');
pll_register_string('coupon_placeholder', 'Промокод', 'Checkout');
pll_register_string('apply_coupon_button', 'Применить', 'Checkout');
pll_register_string('error_invalid_coupon', 'Ошибка! Промокод введен неверно или не существует.', 'Checkout');
pll_register_string('remove_coupon_button', 'Удалить', 'Checkout');
pll_register_string('Применен промокод:', 'Применен промокод:', 'Checkout');
pll_register_string('shipping_method_cdek_courier', 'Курьером', 'Checkout');
pll_register_string('shipping_method_pickup_point', 'Пункт выдачи', 'Checkout');
pll_register_string('shipping_method_time', 'время', 'Checkout');
pll_register_string('shipping_method_price', '₽', 'Checkout');
pll_register_string('shipping_method_no_available', 'Нет доступных способов доставки. Для отображение доступных методов укажите ваш город.', 'Checkout');
pll_register_string('shipping_to', 'Shipping to %s.', 'Checkout');
pll_register_string('change_address', 'Change address', 'Checkout');
pll_register_string('shipping_options_updated', 'Shipping options will be updated during checkout.', 'Checkout');
pll_register_string('Товары', 'Товары', 'Checkout');
pll_register_string('Начните вводить ваш email', 'Начните вводить ваш email', 'Checkout');
pll_register_string('Населенный пункт', 'Населенный пункт', 'Checkout');
pll_register_string('Ваш город', 'Ваш город', 'Checkout');
pll_register_string('Оплатить', 'Оплатить', 'Checkout');
});

@ -1,42 +1,75 @@
jQuery(document).ready(function($) {
// Static translations for both English and Russian
var translations = {
en: {
error_coupon_empty: 'Please enter the coupon code.',
error_coupon_invalid: 'Error! The coupon code is invalid or does not exist.',
error_generic: 'An error occurred. Please try again.',
shipping_method_error: 'No pickup point selected for delivery.',
shipping_address_error: 'Delivery address not provided',
email_taken_error: 'This email is already registered. Please log in or provide a different email.',
phone_number_error: 'Incorrect phone number entered.',
shipping_method_missing: 'No delivery method selected. Please check your address or contact the site administration for help.',
change_address: 'Change address',
shipping_updated: 'Shipping methods will be updated during checkout.',
coupon_applied : 'Coupon applied: '
},
ru: {
error_coupon_empty: 'Пожалуйста, введите код купона.',
error_coupon_invalid: 'Ошибка! Промокод введен неверно или не существует.',
error_generic: 'Произошла ошибка. Попробуйте ещё раз.',
shipping_method_error: 'Не выбран ПВЗ для доставки заказа.',
shipping_address_error: 'Не указан адрес доставки',
email_taken_error: 'Этот email уже зарегистрирован. Войдите в свой аккаунт или укажите другой E-mail.',
phone_number_error: 'Неправильно введен номер',
shipping_method_missing: 'Не выбран метод доставки. Пожалуйста перепроверьте ваш адрес или обратитесь за помощью к администрации сайта.',
change_address: 'Изменить адрес',
shipping_updated: 'Методы доставки будут обновлены в процессе оформления заказа.',
coupon_applied : 'Применен промокод: '
}
};
// Get the current language (assuming you're using a data-lang attribute on the body or html tag)
var currentLang = $('body').data('lang') || 'en'; // Default to 'en' if no lang attribute is found
// Use the correct translations based on the current language
var currentTranslations = translations[currentLang];
jQuery(document.body).on('updated_checkout', function() {
// Найти новые методы доставки внутри shop_table
var shippingMethodsHtml = jQuery('.woocommerce-checkout-review-order-table .woocommerce-shipping-methods').html();
// Обновить кастомный блок
if(!shippingMethodsHtml){
shippingMethodsHtml ='<p>Не удалось получить доступные методы доставки! <br>Укажите свой город для получения доступных методов.</p>'
if (!shippingMethodsHtml) {
shippingMethodsHtml = '<p>' + currentTranslations.shipping_method_missing + '</p>';
}
jQuery('#custom-shipping-methods').html(shippingMethodsHtml);
jQuery('.order-contacts__delivery').removeClass('loading');
jQuery('.modal-map-control__item.active').click()
jQuery('.modal-map-control__item.active').click();
});
$(document.body).on('update_checkout', function() {
jQuery('.order-contacts__delivery').addClass('loading');
});
$('body').on('click', '.modal-map-control__item', function(){
if (!$(this).hasClass('active')){
$('#addr_inp').val('')
$('#pvz_inp').val('')
$('#billing_address_1').val('')
$('#billing_address_2').val('')
$('#addr_inp').val('');
$('#pvz_inp').val('');
$('#billing_address_1').val('');
$('#billing_address_2').val('');
}
$('.shipping-add-info').removeClass('active')
var remote = $(this).data('remote')
$('.shipping-add-info[data-remote="' + remote + '"]').addClass('active')
})
$('.shipping-add-info').removeClass('active');
var remote = $(this).data('remote');
$('.shipping-add-info[data-remote="' + remote + '"]').addClass('active');
});
jQuery('#addr_inp').on('click', function(){
jQuery('#address_input').addClass('active')
})
jQuery('#address_input').addClass('active');
});
});
jQuery(document).ready(function($) {
// Перехват отправки формы купона
$(document).on('click', 'button[name="apply_coupon"]', function(e) {
@ -46,7 +79,7 @@ jQuery(document).ready(function($) {
var couponCode = $('#coupon_code').val();
if (!couponCode) {
alert('Пожалуйста, введите код купона.');
alert(currentTranslations.error_coupon_empty); // Using translated string
return;
}
@ -60,64 +93,60 @@ jQuery(document).ready(function($) {
success: function(response) {
if (response.success) {
$(document.body).trigger('update_checkout');
$('#promo_form').hide()
$('#promo_delete').show()
$('#promo_err').hide()
$('#coupon_code_app').val('Применен промокод: ' + couponCode)
$('#delete_coupon').data('coupon', couponCode)
$('#promo_form').hide();
$('#promo_delete').show();
$('#promo_err').hide();
$('#coupon_code_app').val(coupon_applied + ' ' + couponCode);
$('#delete_coupon').data('coupon', couponCode);
} else {
$('#promo_err').show()
$('#promo_err').show();
}
},
error: function() {
alert('Произошла ошибка. Попробуйте ещё раз.');
alert(currentTranslations.error_generic); // Using translated string
}
});
});
jQuery('#pvz_inp').on('click', function(){
jQuery('.open-pvz-btn').click()
})
jQuery('.open-pvz-btn').click();
});
$('#address_input input').on('change, input, keyup', function(){
var address = $('#f_address').val()
var apart = $('#f_apartment').val()
var floor = $('#f_floor').val()
var entrance = $('#f_entrance').val()
var number_phone = $('#f_number-phone').val()
$('#address_input input').on('change input keyup', function(){
var address = $('#f_address').val();
var apart = $('#f_apartment').val();
var floor = $('#f_floor').val();
var entrance = $('#f_entrance').val();
var number_phone = $('#f_number-phone').val();
var address_2 = ''
var address_2 = '';
if (apart){
address_2 += ' кв ' + apart
if (apart) {
address_2 += ' кв ' + apart;
}
if (floor){
address_2 += ' этаж ' + floor
if (floor) {
address_2 += ' этаж ' + floor;
}
if (entrance){
address_2 += ' подъезд ' + entrance
if (entrance) {
address_2 += ' подъезд ' + entrance;
}
if (number_phone){
address_2 += ' домофон ' + number_phone
if (number_phone) {
address_2 += ' домофон ' + number_phone;
}
$('#addr_inp').val(address + address_2)
$('#billing_address_1').val(address)
$('#billing_address_2').val(address_2)
})
});
$('#addr_inp').val(address + address_2);
$('#billing_address_1').val(address);
$('#billing_address_2').val(address_2);
});
});
jQuery(document).ready(function ($) {
$(document.body).on('checkout_error', function () {
// $('.woocommerce-error').remove();
$('.form-input__error').removeClass('active');
// // Добавляем ошибки рядом с полями
$('.woocommerce-error li').each(function () {
var errorMessage = $(this).text().trim();
var fieldKey = $(this).data('id'); // Предполагается, что ошибка содержит data-id
console.log(errorMessage)
console.log(fieldKey)
var fieldKey = $(this).data('id');
if (fieldKey) {
var errorContainer = $('#' + fieldKey + '-error');
if (errorContainer.length) {
@ -125,40 +154,35 @@ jQuery(document).ready(function ($) {
$('#' + fieldKey + '-error').addClass('active');
}
}
if (errorMessage == 'phone_err' || errorMessage == 'The string supplied did not seem to be a phone number.' || errorMessage.includes('Некорректный номер телефона')){
$('#billing_phone-error').html('Неправильно введен номер')
$('#billing_phone-error').addClass('active');
if (errorMessage == 'phone_err' || errorMessage == 'The string supplied did not seem to be a phone number.' || errorMessage.includes('Некорректный номер телефона')) {
$('#billing_phone-error').html(currentTranslations.phone_number_error).addClass('active'); // Using translated string
}
if (errorMessage == 'Order pickup point not selected.' || errorMessage == 'Не выбран ПВЗ для доставки заказа.'){
$('#pvz-error').html('Не выбран ПВЗ для доставки заказа.')
$('#pvz-error').addClass('active');
if (errorMessage == 'Order pickup point not selected.' || errorMessage == 'Не выбран ПВЗ для доставки заказа.') {
$('#pvz-error').html(currentTranslations.shipping_method_error).addClass('active'); // Using translated string
}
if (errorMessage == 'adress_error'){
$('#adr-error').html('Не указан адрес доставки')
$('#adr-error').addClass('active');
if (errorMessage == 'adress_error') {
$('#adr-error').html(currentTranslations.shipping_address_error).addClass('active'); // Using translated string
}
if (errorMessage == 'Неверный адрес эл. почты для выставления счета'){
if (errorMessage == 'Неверный адрес эл. почты для выставления счета') {
$('#billing_email-error').html(errorMessage).addClass('active');
}
if(errorMessage == 'Не выбран метод доставки. Пожалуйста перепроверьте ваш адрес или обратитесь за помощью к администрации сайта.'){
if (errorMessage == 'Не выбран метод доставки. Пожалуйста перепроверьте ваш адрес или обратитесь за помощью к администрации сайта.') {
$('#billing_city-error').html(errorMessage).addClass('active');
}
if(errorMessage == 'Этот email уже зарегистрирован.'){
$('#acc-error').html('Этот email уже зарегистрирован. Войдите в свой аккаунт или укажите другой E-mail.').addClass('active');
if (errorMessage == 'Этот email уже зарегистрирован.') {
$('#acc-error').html(currentTranslations.email_taken_error).addClass('active'); // Using translated string
}
});
});
$('#delete_coupon').on('click', function(){
$('.woocommerce-remove-coupon[data-coupon=' + $(this).data('coupon') + ']').click()
$('#promo_form').show()
$('#promo_delete').hide()
})
$('.woocommerce-remove-coupon[data-coupon=' + $(this).data('coupon') + ']').click();
$('#promo_form').show();
$('#promo_delete').hide();
});
$('.woocommerce-remove-coupon').on('click', function(){
$('#promo_form').show()
$('#promo_delete').hide()
})
$('#promo_form').show();
$('#promo_delete').hide();
});
});

@ -31,40 +31,40 @@ function customize_billing_fields( $fields ) {
// Перенастраиваем только нужные поля
$fields['billing']['billing_first_name'] = array(
'type' => 'text',
'label' => __('Имя', 'woocommerce'),
'placeholder' => __('Ваше имя', 'woocommerce'),
'label' => pll__('Имя', 'woocommerce'),
'placeholder' => pll__('Ваше имя', 'woocommerce'),
'required' => true,
'class' => array('form-row-wide'),
'priority' => 10,
);
$fields['billing']['billing_last_name'] = array(
'type' => 'text',
'label' => __('Фамилия', 'woocommerce'),
'placeholder' => __('Ваша фамилия', 'woocommerce'),
'label' => pll__('Фамилия', 'woocommerce'),
'placeholder' => pll__('Ваша фамилия', 'woocommerce'),
'required' => true,
'class' => array('form-row-wide'),
'priority' => 10,
);
$fields['billing']['billing_email'] = array(
'type' => 'email',
'label' => __('E-mail', 'woocommerce'),
'placeholder' => __('Начните вводить ваш email', 'woocommerce'),
'label' => pll__('E-mail', 'woocommerce'),
'placeholder' => pll__('Начните вводить ваш email', 'woocommerce'),
'required' => true,
'class' => array('form-row-wide'),
'priority' => 20,
);
$fields['billing']['billing_phone'] = array(
'type' => 'tel',
'label' => __('Телефон', 'woocommerce'),
'placeholder' => __('+7 ___ ___ ____', 'woocommerce'),
'label' => pll__('Телефон', 'woocommerce'),
'placeholder' => pll__('+7 ___ ___ ____', 'woocommerce'),
'required' => true,
'class' => array('form-row-wide'),
'priority' => 30,
);
$fields['billing']['billing_city'] = array(
'type' => 'text',
'label' => __('Населенный пункт', 'woocommerce'),
'placeholder' => __('Ваш город', 'woocommerce'),
'label' => pll__('Населенный пункт', 'woocommerce'),
'placeholder' => pll__('Ваш город', 'woocommerce'),
'required' => true,
'class' => array('form-row-wide'),
'priority' => 40,
@ -72,16 +72,16 @@ function customize_billing_fields( $fields ) {
$fields['billing']['billing_address_1'] = array(
'type' => 'text',
'label' => __('Адрес', 'woocommerce'),
'placeholder' => __('Адрес', 'woocommerce'),
'label' => pll__('Адрес', 'woocommerce'),
'placeholder' => pll__('Адрес', 'woocommerce'),
'required' => false,
'class' => array('visually-hidden'),
'priority' => 40,
);
$fields['billing']['billing_address_2'] = array(
'type' => 'text',
'label' => __('Адрес 2', 'woocommerce'),
'placeholder' => __('Адрес 2', 'woocommerce'),
'label' => pll__('Адрес 2', 'woocommerce'),
'placeholder' => pll__('Адрес 2', 'woocommerce'),
'required' => false,
'class' => array('visually-hidden'),
'priority' => 40,
@ -133,7 +133,7 @@ add_filter( 'woocommerce_order_button_html', 'custom_checkout_button_classes' );
function custom_checkout_button_classes( $button ) {
// Заменяем стандартные классы
$button = '<div class="order-your-calculation__submit">
<button type="submit" class="button alt button--gradient button--high button--100-perc" name="woocommerce_checkout_place_order" id="place_order" value="Оплатить" data-value="Оплатить"><span>Оплатить</span></button>
<button type="submit" class="button alt button--gradient button--high button--100-perc" name="woocommerce_checkout_place_order" id="place_order" value="' . pll__('Оплатить') . '" data-value="' . pll__('Оплатить') . '"><span>' . pll__('Оплатить') . '</span></button>
</div>';
return $button;
}

@ -46,11 +46,12 @@ $calculator_text = '';
$text_before_comma = '';
$text_in_parentheses = '';
}
if ($text_before_comma == 'CDEK: Посылка склад-дверь'){
$title = 'Курьером';
if ($text_before_comma == 'CDEK: Посылка склад-дверь' || $text_before_comma == 'CDEK: Package warehouse to door'){
$title = pll__('Курьером');
}
else if ($text_before_comma == 'CDEK: Посылка склад-склад'){
$title = 'Пункт выдачи';
else if ($text_before_comma == 'CDEK: Посылка склад-склад' || $text_before_comma == 'CDEK: Package warehouse to warehouse'){
$title = pll__('Пункт выдачи');
}
?>
@ -103,7 +104,7 @@ $calculator_text = '';
<?php
else:
?>
<p> Нет доступных способов доставки. Для отображение доступных методов укажите ваш город.</p>
<p> <?php pll_e('Нет доступных способов доставки. Для отображение доступных методов укажите ваш город.') ?></p>
<?php

@ -28,7 +28,7 @@ if ( ! wc_coupons_enabled() ) { // @codingStandardsIgnoreLine.
$applied_coupons = WC()->cart->get_applied_coupons();
if($applied_coupons){
$first_coupon = $applied_coupons[0];
$cText = 'Применен промокод: ' . $first_coupon;
$cText = pll__('Применен промокод:') . $first_coupon;
$coupon = $applied_coupons[0];
}
else{
@ -38,12 +38,12 @@ else{
?>
<div action="" class="order-your__promo" id="promo_form" <?php if ( !empty( $applied_coupons ) ) { echo 'style="display: none;"'; } ?>>
<input type="text" name="coupon_code" class="form__input form__input--grey" placeholder="Промокод" id="coupon_code" value="" />
<button type="button" class="button button--white button--red-48-px active order-your-promo__button" name="apply_coupon" value="Применить">Применить</button>
<span class="form-input__error form-input__error--absolute" id="promo_err">Ошибка! Промокод введен неверно или не существует.</span>
<input type="text" name="coupon_code" class="form__input form__input--grey" placeholder="<?php pll_e('Промокод') ?>" id="coupon_code" value="" />
<button type="button" class="button button--white button--red-48-px active order-your-promo__button" name="apply_coupon" value="<?php pll_e('Применить') ?>"><?php pll_e('Применить') ?></button>
<span class="form-input__error form-input__error--absolute" id="promo_err"><?php pll_e('Ошибка! Промокод введен неверно или не существует.') ?></span>
</div>
<div action="" class="order-your__promo" id="promo_delete" <?php if ( empty( $applied_coupons ) ) { echo 'style="display: none;"'; } ?>>
<input type="text" name="coupon_code_applied" readonly class="form__input form__input--grey" placeholder="Промокод" id="coupon_code_app" value="<?php echo $cText; ?>" />
<button type="button" class="button button--white button--red-48-px active order-your-promo__button" id="delete_coupon" value="Применить" data-coupon="<?php echo $coupon; ?>">Удалить</button>
<button type="button" class="button button--white button--red-48-px active order-your-promo__button" id="delete_coupon" value="<?php pll_e('Применить') ?>" data-coupon="<?php echo $coupon; ?>"><?php pll_e('Удалить') ?></button>
</div>

@ -30,7 +30,7 @@ defined( 'ABSPATH' ) || exit;
<tfoot>
<tr class="order-your-calculation__item">
<th class="order-your-calculation__title">Товары</th>
<th class="order-your-calculation__title"><?php pll_e('Товары') ?></th>
<td class="order-your-calculation__value order-your-calculation__value--price"><?php wc_cart_totals_subtotal_html(); ?></td>
</tr>
@ -52,12 +52,12 @@ defined( 'ABSPATH' ) || exit;
<?php endif; ?>
<tr class="order-your-calculation__item">
<th class="order-your-calculation__title">Доставка</th>
<th class="order-your-calculation__title"><?php pll_e('Доставка') ?></th>
<?php
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
?>
<?php if (!isset( $chosen_shipping_methods[0])): ?>
<td class="order-your-calculation__description">Введите адрес доставки</td>
<td class="order-your-calculation__description"><?php pll_e('Введите адрес доставки') ?></td>
<?php
else:
?>

Loading…
Cancel
Save