在WooCommerce结帐页面上将“帐单明细”文本更改为“运输明细”

问题描述 投票:1回答:2

我目前在我的子主题的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兼容的代码段。

php wordpress woocommerce translation checkout
2个回答
12
投票
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测试确定是否正常


4
投票

要覆盖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 &amp; Shipping', 'woocommerce' ); ?></h3>

<?php else : ?>

    <h3><?php _e( 'Billing details', 'woocommerce' ); ?></h3>

<?php endif; ?>
© www.soinside.com 2019 - 2024. All rights reserved.