我使用代码段在价格之前添加了前缀。效果很好,但我只想在类别产品页面上显示它。
我想在简单的产品页面上隐藏前缀。
你能帮我吗?
谢谢!
使用的摘要:
add_filter( ‘woocommerce_get_price_html’, ‘njengah_text_before_price’ );
function njengah_text_before_price($price){
global $post;
$product_id = $post->ID;
$product_array = array( 25338 );//add in the product IDs to add text after price
if ( in_array( $product_id, $product_array )) {
$text_to_add_before_price = ‘ Cena od ‘; //change text in bracket to your preferred text
return $text_to_add_before_price . $price ;
}else{
return $price;
}
}