If I am on a product or any category/subcategory I want to display a complete path to the topmost category. Does WooCommerce already have a function for it or do I need to make my own loop that goes from child to parent? Should I use $wp_query->get_queried_object()? What is the best code for it?
I think you may look for breadcrumb? Can you try it?
<?php woocommerce_breadcrumb(); ?>
This link may help: https://docs.woocommerce.com/document/woocommerce_breadcrumb/