在Woocommerce中,我想在单个产品页面上更改价格。没有与此文本关联的类或ID,也不知道它在哪个文件夹中:
<p class="price"><span class="woocommerce-Price-amount amount">35.00 <span class="woocommerce-Price-currencySymbol">€</span></span> Prix hors taxes</p>
有人有想法吗?任何帮助表示赞赏。
要从显示的价格中删除“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文件中。测试和工作。