display woocommerce all category title on home page

<?php

$post_type="product";

$taxonomies = get_object_taxonomies((object) array( 'post_type' => $post_type ));

foreach ($taxonomies as $taxonomy) : 

    $terms = get_terms($taxonomy);

    foreach ($terms as $term) : 

        $term_link = get_term_link($term->term_id);

        $posts = new WP_Query( "taxonomy=$taxonomy&term=$term->slug&posts_per_page=2" ); ?>

        <li>

            <h2>
                <a href="https://wordpress.stackexchange.com/questions/218036/<?php echo $term_link; ?>"><?php echo $term->name; ?></a>
            </h2>

            <?php 

            if( $posts->have_posts() ): while( $posts->have_posts() ) : $posts->the_post(); ?>

                <div>

                <?php if( get_field('hexagon_thumbnail') ): ?>

                    <img src="https://wordpress.stackexchange.com/questions/218036/<?php the_field("hexagon_thumbnail'); ?>" />

                <?php endif; ?>

                </div>

            <?php endwhile; endif; ?>

        </li> <!-- end list item -->

<?php endforeach; endforeach; ?>