In WooCommerce, I use the following code:
<?php
global $product;
$terms = get_the_terms( $product->get_id(), 'product_tag' );
for ($i = 0; $i < count($terms); $i++) {
$tags[] = $terms[$i]->slug;
}
?>
<?php if ( $price_html = $product->get_price_html() ) : ?>
<?php if (is_user_logged_in() && in_array('HIDDEN TAG', $tags)): ?>
<span class="price">Please Log-in</span>
<?php else: ?>
<span class="price"><?php echo $price_html; ?></span>
<?php endif; ?>
<?php endif; ?>
On products, this code should replace price by "Please Log-in" when customer is not logged on products that have 'HIDDEN TAG' product tag.
I don't understand why it doesn't work. Any help is appreciated.