In your first code block try changing return $output;
with echo $output;
and that should work provided $output
is not empty 🙂
If you are trying to append your custom field to the product summary, this can be very well achieved using woocommerce_short_description
filter hook. Please see below code:
function add_subtitle_to_product() {
global $post;
if (get_field('subtitle', get_the_ID()))
return $post->post_excerpt . ''.get_field('subtitle', get_the_ID()).'';
else
return $post->post_excerpt;
}
add_action( 'woocommerce_short_description', 'add_subtitle_to_product', 10, 2 );