【发布时间】:2019-07-16 19:16:13
【问题描述】:
我正在使用自定义代码来修改我的价格后缀,所以我没有通过 woocommerce 设置显示它,我在我的 function.php 中使用此代码来获取产品页面上的价格后缀。
function change_product_price_html($price){
$newPrice .= $price;
$newPrice .= " <span class=\"woocommerce-price-suffix\">inkl. MwSt., <a href='https://www.amaoni.de/zahlung-versand#versandkosten'>zzgl. Versandkosten</a></span>";
return $newPrice;
}
但现在它也在类别页面上显示价格后缀。
我找到了这个对我不起作用的解决方案。
add_filter('woocommerce_get_price_html', 'hide_price_on_shop');
function hide_price_on_shop($price){
if(is_shop()){
$price = '';
}
return $price;
}
有没有办法让价格后缀只出现在产品页面而不出现在类别页面上?
【问题讨论】:
标签: php woocommerce