I'm trying to add my own custom fields to the single product summary after the main product's title output on my product page. I've looked into the woocommerce documentation (https://github.com/woothemes/woocommerce/blob/2.3.8/templates/content-single-product.php) and it looks like woocommerce_single_product_summary is my hook. So here's what I did:
// should hook into woocommerce single product summary and output info
function add_subtitle_to_product() {
if (get_field('subtitle', get_the_ID())) {
$output = '<h4>'.get_field('subtitle', get_the_ID()).'</h4>';
}
return $output;
}
add_action( 'woocommerce_single_product_summary', 'add_subtitle_to_product', 6 );
And it wasn't working. I even made sure the get_field() call was returning true. So I decided to try a different approach:
// hook into woocommerce product summary and output test text
add_action('woocommerce_single_product_summary', function() {
$output = '<p>Test</p>';
return $output;
}, 7);
I tried this as a normal function with a name but that didn't work so I opted for an anonymous function that still isn't working.
What could be my issue?