Skip to content

Instantly share code, notes, and snippets.

@DmitryBychenko
Created May 16, 2026 13:21
Show Gist options
  • Select an option

  • Save DmitryBychenko/1eb88e8eff6731bc91d636e4ace54f69 to your computer and use it in GitHub Desktop.

Select an option

Save DmitryBychenko/1eb88e8eff6731bc91d636e4ace54f69 to your computer and use it in GitHub Desktop.
/**
* Способ 2: Изолированный фильтр gettext для WooCommerce
* Используется как запасной вариант для тем с кастомной структурой шаблонов.
*/
add_filter( 'gettext', 'tb_classic_heavy_cart_strings', 20, 3 );
function tb_classic_heavy_cart_strings( $translated_text, $text, $domain ) {
// Мгновенно отсекаем проверку строк вне WooCommerce и в админке
if ( is_admin() || 'woocommerce' !== $domain ) {
return $translated_text;
}
// Перехватываем оригинальные английские исходники строк
switch ( $text ) {
case 'Proceed to checkout':
case 'Proceed to Checkout':
return __( 'Выложить из Корзины и Оплатить', 'techbear-custom' );
break;
case 'Update cart':
case 'Update Cart':
return __( 'Пересчитать товары в Корзине', 'techbear-custom' );
break;
case 'View cart':
case 'View Cart':
return __( 'Посмотреть что в Корзине', 'techbear-custom' );
break;
}
return $translated_text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment