I would like to display a piece of text after the price tag in WooCommerce. I have a code that is working for my functions.php, but it shows on all product categories.
I was wondering if someone knows how to make this custom text to show for only selected categories; or even better, unselected product categories as there are a lot more product categories that will display the text than the ones who doesn't.
My actual code:
add_filter( 'woocommerce_get_price_html', 'custom_price_message' );
function custom_price_message( $price ) {
$mt = ' per M/T';
return $price . $mt;
}
Any help on this please.
Try the following code that uses
has_term()
conditional function for defined product categories:Code goes in function.php file of your active child theme (or active theme). Tested and works.
To exclude defined product categories you will replace:
simply by: