Ok, I searched everywhere and by recovering pieces of code I was able to make a hook adapted to my Flatsome theme. But I think the part to recover the parent can be useful to others.
function flatsome_woocommerce_shop_custom_category() {
if ( ! flatsome_option( 'product_box_category' ) ) {
return;
} ?>
<p class="category uppercase is-smaller no-text-overflow product-cat op-7">
<?php
global $product;
$curr_cat = get_queried_object();
if($curr_cat->parent > 0):
$parentcats = get_ancestors($curr_cat->term_id, 'product_cat');
foreach($parentcats as $parent):
$cat = get_term($parent,'product_cat');
$cat_name = $cat->name;
endforeach;
else:
$cat_name = $curr_cat->name;
endif;
echo $cat_name;
?>
</p>
<?php
}
// I cancel the addition of the category of the woocomerce function of the parent theme
add_action( 'woocommerce_init', function(){
remove_action( 'woocommerce_shop_loop_item_title', 'flatsome_woocommerce_shop_loop_category', 0 );
} );
// I add my function instead
add_action( 'woocommerce_shop_loop_item_title', 'flatsome_woocommerce_shop_custom_category', 0 );
?>