The thing is that I wanted to add a hook on single page, so that if the product hasn't got a price then add a custom button that leads to contact page. The validation I make on the hook is that if I am on single product page. Everythings works fine but the thing is that I also see the button on related products beneath. How I can hook only inside the current single product that I am looking and not the single product page? This is the code I use now:
add_filter('woocommerce_empty_price_html', 'custom_free_price_text');
function custom_free_price_text($product)
{
if (is_product()) {
global $product;
$price = $product->get_price();
if ($price == '') {
ob_start();
//my code..
}
}
}