I've created a custom field in Woocommerce to link to games that have the same title but are on different platforms. It basically shows Also available on: XBox One or PS4. It works well but when the field is empty it shows only Also available on: which looks sloppy and is confusing.
How can I hide the custom field when it's empty? The code is below and the custom field is also_available. I've placed it in my functions.php
add_action( 'woocommerce_single_product_summary', 'also_available_on_ps4', 38 );
function also_available_on_ps4() {
global $product;
if ( has_term( 'ps4-games', 'product_cat' ) ) {
echo '<b>Also available on:</b>' . get_post_meta( get_the_ID(), 'also_available', true );
}
}
I hope someone can help me. TIA