I have added a custom button to product page that is connected to product meta demo_url, which is just an URL that changes by each product (to open live demo for each product separately in a lightbox). The code is quite simple:
function my_extra_button_on_product_page() {
global $product;
$demo_url = get_post_meta( get_the_ID(), 'demo_url', true );
echo '<a class="fancybox iframe" data-width="1280" data-height="720" href="'.$demo_url.'"><button style="background: lightblue; padding-left: 19px; padding-right: 19px;">Przymierz</button></a>';
}
The thing is, there are some other products in the shop that do not use live demo function. They are listed in different categories. I would like this button to be visible ONLY for certain product category (or invisible for two product categories - whatever is easier).
I suppose this should be done via get_cat_ID( $cat_name ), but I am unsure how to write the if function and generally I'm quite inexperienced in coding. Maybe something like this could work?
if get_cat_ID( $cat_name ) = categoryname {
echo 'button code';
else
echo 'no button code';
endif
}
How can I make it work?
Thanks