Get parent category name when only child category is applied to a product

Check if it works for you… i have modified the loop
/Woo Cat product
$woo_single_cats = get_the_terms( $post->ID, ‘product_cat’ );

    if ( $woo_single_cats && ! is_wp_error( $woo_single_cats ) ) {
        
        $woo_single_cat = array();
        
        foreach ( $woo_single_cats as $term ) {
            $woo_single_cat[$term->term_id] = $term->name;
            $term_parent_id = $term->parent;
            $parent_term  = get_term($term_parent_id, 'product_cat');
              
        }

        $woo_single_cat = apply_filters('seopress_titles_product_cat', $woo_single_cat);

        $woo_single_cat_html = stripslashes_deep(wp_filter_nohtml_kses(join( " - ", $woo_single_cat )));
    }