我试图仅在产品页面上的价格后面显示后缀。我不想在其他地方显示这个后缀。
我没有使用“税收”设置,因为我的价格已包含在内,并且我不想使用“税收”选项使设置变得复杂。
使用此答案中代码片段中的第一条路线/sf/answers/4005328631/
我的代码是:
## Add suffix to price on Product Page
add_filter( 'woocommerce_get_price_html', 'custom_price_suffix', 100, 2 );
function custom_price_suffix( $price, $product ) {
    if(is_singular('product')) {
        $price = $price . ' <span class="make-me-small"> Inclusive of all taxes</span>';
    }
    return apply_filters( 'woocommerce_get_price', $price );
}
##-End of above code - Start new code below
Run Code Online (Sandbox Code Playgroud)
但是,此代码片段显示了相关产品中的后缀。
我应该做什么更改才能防止在相关产品中显示后缀
这个问题类似于woocommerce 登录页面上的重命名用户名标签
我正在尝试将标签“用户名或电子邮件地址”更改为“您注册的电子邮件地址”
我试图在不修改 form-login.php 模板文件的情况下执行此操作。
到目前为止,我尝试了以下代码:
function wppb_change_text_login( $translated_text, $text ) {
    //Login page
    $original_text = 'Username or email address';
    $new_text = 'Your registered email address';
    if ( $text == $original_text ) {
        $translated_text = $new_text;
    }
}
add_filter( 'gettext', 'wppb_change_text_login', 30, 2 );
Run Code Online (Sandbox Code Playgroud)
但是,我知道 gettext 是非常占用资源的功能,我想知道应该进行哪些更改才能使这些更改仅限于我的帐户页面。