kikirikimiki
Active member
- Jul 1, 2020
- 166
- 154
- 43
Hello everyone,
I am trying some filtering with code injected with the snippets plugin - code looks something like this:
add_filter( 'woocommerce_get_price_html', 'hide_price_for_category', 10, 2 );
function hide_price_for_category( $price_html, $product ) {
// List of category slugs for which I want to hide the price to
$category_slugs = array( 'power-management' );
// Check if the product is in one of the specified categories
if ( has_term( $category_slugs, 'product_cat', $product->get_id() ) ) {
$price_html = '';
}
return $price_html;
}
where my target category's slug is 'power-management' - to no avail. Is there a plugin that does a better job ? Thank you!
I am trying some filtering with code injected with the snippets plugin - code looks something like this:
add_filter( 'woocommerce_get_price_html', 'hide_price_for_category', 10, 2 );
function hide_price_for_category( $price_html, $product ) {
// List of category slugs for which I want to hide the price to
$category_slugs = array( 'power-management' );
// Check if the product is in one of the specified categories
if ( has_term( $category_slugs, 'product_cat', $product->get_id() ) ) {
$price_html = '';
}
return $price_html;
}
where my target category's slug is 'power-management' - to no avail. Is there a plugin that does a better job ? Thank you!