Get category slug of the Parent category of a Product

Put this below code in functions.php and Try it.

add_action( 'woocommerce_before_single_product', 'content_before_addtocart_button' );
function content_before_addtocart_button() {
    global $post;
    $categories = array();
    $taxonomies = get_terms( array(
        'taxonomy' => 'product_cat',
        'hide_empty' => false,
        'parent'   => 0
    ));
    if ( !empty($taxonomies) ) :
        foreach( $taxonomies as $taxonomy ) {
            $categories[] = $taxonomy->slug; 
        }
    endif;
    $terms = get_the_terms( $post->ID, 'product_cat' );
    if($terms[0]->parent != 0){
        $parent_category = get_term( $terms[0]->parent, 'product_cat' );
        $parent_category_slug = $parent_category->slug;
        foreach ($terms as $term) {
            if(in_array( $parent_category_slug ,$categories )){
                echo '<div class="content-section"><a href="' . esc_url( get_term_link( $term->term_id, 'product_cat' ) ) . '">' . 'Back to Other Designs'. '</a></div>';
            }
        }
    }else{
        echo '<div class="content-section"><a href="' . esc_url( get_term_link( $terms[0]->term_id, 'product_cat' ) ) . '">' . 'Back to Other Designs'. '</a></div>';
    }
}