2016-10-28 95 views
0

当您将鼠标悬停在购物车图标上时,它会显示“查看您的购物车”。我的客户希望这个标题说“查看你的购物篮”。如何更改WooCommerce迷你购物车标题Atrribute

我已经找遍了模板文件没有运气,似乎无法找到任何function.php代码片段做这项工作。

我得到的最接近是找到“店面,woocommerce-模板的functions.php”文件,下面的代码:

function storefront_cart_link() { 
    ?> 
     <a class="cart-contents" href="<?php echo esc_url(WC()->cart->get_cart_url()); ?>" title="<?php esc_attr_e('View your shopping cart', 'storefront'); ?>"> 
      <span class="amount"><?php echo wp_kses_data(WC()->cart->get_cart_subtotal()); ?></span> <span class="count"><?php echo wp_kses_data(sprintf(_n('%d item', '%d items', WC()->cart->get_cart_contents_count(), 'storefront'), WC()->cart->get_cart_contents_count()));?></span> 
     </a> 
    <?php 
} 

但是没有我在这里做了网站上的任何影响。

解决:

add_filter('gettext', 'translate_reply'); 
add_filter('ngettext', 'translate_reply'); 

function translate_reply($translated) 
{ 
$translated = str_ireplace('Shipping', 'Delivery', $translated); 
$translated = str_ireplace('View your shopping cart', 'View your shopping basket', $translated); 

return $translated; 
} 
+0

这是你想要做什么http://stackoverflow.com/questions/18481472/change-the-text-of-view-cart-button? –

回答

1
add_filter('gettext', 'translate_reply'); 
add_filter('ngettext', 'translate_reply'); 

function translate_reply($translated) 
{ 
$translated = str_ireplace('Shipping', 'Delivery', $translated); 
$translated = str_ireplace('View your shopping cart', 'View your shopping basket', $translated); 

return $translated; 
} 

作品就好了!

+0

优秀!!!!!! –

1

你可以一个过滤器添加到get_text挂钩,因为这不是一个很暧昧的字符串:

add_filter('gettext', 'gb_modify_view_shopping_title'); 

function gb_modify_view_shopping_title($translated_text, $text, $domain){ 

    if($translated_text == 'View your shopping cart') 
     return 'View your shopping basket'; 

    return $translated_text; 

} 
+0

嗨乔治 - 我实际上使用这个另一个查询。反正有'重用'它吗?我已附加到我原来的帖子 – DavidPottrell

相关问题