Add caption to product images in woo commerce

Hi Apex
I would like to show image captions for the product images in woocommerce. I know that I can add this:

<?php if ( $caption = get_post( get_post_thumbnail_id() )->post_excerpt ) : ?>
<p class="caption"><?php echo $caption; ?></p>
<?php endif; ?>

to the product image template file, but I am not sure how to make a copy of the correct template file to put in my child theme.
Can you help please.
Thank you.
Tamsin

Hi there,

Kindly consider that this is not related to our theme and the question is about the core Woocommerce functionality.

We also need to search around to find such a solution as customizing the plugins even if it is the recommended one from Themeco is not part of our support scope.

I did a little bit of research and found out this which I think can be of a help:

So try to add the code below to your Child Theme:

add_filter( 'wp_get_attachment_image_attributes','wdm_shop_image_caption_func', 10,3 );
function wdm_shop_image_caption_func($attr, $attachment, $size){
    $attr['title']=$attr['alt'];
    return $attr;
}

Use the code with caution as we did not test it in our local installation.

Thank you.