jFi*_*ish 0 php wordpress checkout woocommerce
我目前在我的孩子主题的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 );
Run Code Online (Sandbox Code Playgroud)
我真的很喜欢与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 );
Run Code Online (Sandbox Code Playgroud)
使用WooCommerce 3.0.6测试好了
小智 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; ?>
Run Code Online (Sandbox Code Playgroud)