Woocommerce 3.0 - 更改“帐单详细信息”以在结算页上显示“发货详细信息”页面
问题描述:
我目前在我的子主题的functions.php文件中有一些代码,应该将“帐单详细信息”更改为“发货详情”在我的Woocommerce结帐页面上。Woocommerce 3.0 - 更改“帐单详细信息”以在结算页上显示“发货详细信息”页面
但是,当我更新到Woocommerce 3.0时,代码段停止工作。以下是我使用的代码。
function wc_billing_field_strings($translated_text, $text, $domain) {
switch ($translated_text) {
case 'Billing Details' :
$translated_text = __('Shipping Details', 'woocommerce');
break;
}
return $translated_text;
}
add_filter('gettext', 'wc_billing_field_strings', 20, 3);
我真的很喜欢与Woocommerce 3.0一起使用的代码片段。
非常感谢!
答
function wc_billing_field_strings($translated_text, $text, $domain) {
switch ($translated_text) {
case 'Billing details' :
$translated_text = __('Billing Info', 'woocommerce');
break;
}
return $translated_text;
}
add_filter('gettext', 'wc_billing_field_strings', 20, 3);
测试OK与WooCommerce 3.0.6
答
要覆盖woocommerce意见,你需要从woocommerce /模板所需的模板文件复制到你的主题目录。在这种情况下副本woocommerce /模板/结算/ form_billing.php你的主题文件夹woocommerce /结帐/ form_billing.php和编辑下面的代码行周围27
<?php if (wc_ship_to_billing_address_only() && WC()->cart->needs_shipping()) : ?>
<h3><?php _e('Billing & Shipping', 'woocommerce'); ?></h3>
<?php else : ?>
<h3><?php _e('Billing details', 'woocommerce'); ?></h3>
<?php endif; ?>
谢谢@MujeebuRahman!这很好。除了格式化之外,我并没有看到两个代码片段之间的区别,但是您给我的那个代码很好。 – jFish
@ mujeebu-rahman谢谢。你可以添加一个更改多个文本字段的例子吗?例如,也删除“附加信息”标题? –