【发布时间】:2020-06-12 19:07:07
【问题描述】:
我试图在产品页面上仅显示价格后的后缀。我不想在其他任何地方显示这个后缀。
我没有使用税费设置,因为我的价格包含所有费用,并且我不想使用税费选项使设置复杂化。
在此答案https://stackoverflow.com/a/57218980/8044005
上使用代码 sn-p 中的 first route我的代码是:
## 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
但是,此代码 sn-p 显示了相关产品中的后缀。
我应该做哪些更改来防止在相关产品中显示后缀
【问题讨论】:
标签: php wordpress woocommerce hook-woocommerce