[英]Change “Billing Details” text to “Shipping Details” on WooCommerce checkout page
我目前在我的子主題的 functions.php 文件中有一些代碼,它應該在我的 WooCommerce 結帳頁面上將“賬單詳細信息”更改為“運輸詳細信息”。
但是,當我更新到 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 );
使用 WooCommerce 3.0.6 測試正常
要覆蓋 woocommerce 視圖,您需要將所需的模板文件從 woocommerce/templates 復制到您的主題目錄。 在這種情況下,將 woocommerce/templates/checkout/form_billing.php 作為 woocommerce/checkout/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; ?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.