WooCommerce Conditional To Detect When Showing Only Products Archive
When viewing an archive of a WooCommerce product category, there is no way to detect if you are showing an archive of products or an archive of subcategories.
WooCommerce > Settings > Products Tab
Shop Page Display: Show categories
Default Category Display: Show subcategories
This implies that you want to show the categories on the main shop page, then in each category you want to show subcategories only, until you reach an archive with no more subcategories, where you then just show products.
You add the following function to functions.php to detect if you are showing subcategories or an archive of products: