删除Woocommerce单品页面价格后的一些文字[关闭]

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

在Woocommerce中,我想在单个产品页面上更改价格。没有与此文本关联的类或ID,也不知道它在哪个文件夹中:

<p class="price"><span class="woocommerce-Price-amount amount">35.00&nbsp;<span class="woocommerce-Price-currencySymbol">€</span></span> Prix hors taxes</p>

有人有想法吗?任何帮助表示赞赏。

php wordpress woocommerce product price
1个回答
0
投票

要从显示的价格中删除“Prix hors tax”后缀,请尝试以下操作:

add_filter( 'woocommerce_get_price_html', 'filter_get_price_html_callback', 10, 2 );
function filter_get_price_html_callback( $price, $product ) {
    return str_replace( __('Prix hors taxes'), '', $price );
}

代码位于活动子主题(或活动主题)的function.php文件中。测试和工作。


或者仅针对单个产品页面进行定位:

add_filter( 'woocommerce_get_price_html', 'filter_get_price_html_callback', 10, 2 );
function filter_get_price_html_callback( $price, $product ) {
    if ( is_product() )
        $price = str_replace( __('Prix hors taxes'), '', $price );

    return $price;
}

代码位于活动子主题(或活动主题)的function.php文件中。测试和工作。

© www.soinside.com 2019 - 2024. All rights reserved.