Show different menu on each woocommerce category page

I have created several custom menus that appear under the main menu on the shop page. Each category (and its subcategories) should display a different custom menu like below:

custom menu: category1 shows menu1, category2 shows menu2… and so
on.

I tried to achieve this by renaming the taxonomy-product_cat.php file to each category name in order to create different templates, but this doesn’t seem to affect anything.

So I’m guessing the best solution is to modify archive-product.php and add a conditional if (is_product_category( 'cat1' )) that shows the menu if category "cat1" is being displayed. It seems to be a simple solution but I can’t make it work.

Any feedback is very much appreciated.

Solutions Collecting From Web of "Show different menu on each woocommerce category page"

This is the solution I found that works:

As usual in these cases, override the archive product template from your woocommerce plugin folder by copying archive-product.php to yourtheme/woocommerce/archive-product.php. Edit the file, and add this code at the beginning (or wherever the menu needs to show up):

<?php 

if ( is_tax( 'product_cat', 'cat1' )) {
    wp_nav_menu( array( 'theme_location' => 'menu1' ) ); 
}

elseif ( is_tax( 'product_cat', 'cat2' )) {
    wp_nav_menu( array( 'theme_location' => 'menu2' ) ); 
}

else ( is_tax( 'product_cat', 'cat3' )) {
    wp_nav_menu( array( 'theme_location' => 'menu3' ) ); 
}

?>

menu1 will be displayed when we’re on the products page that belongs to category cat1.

menu2 will be displayed when we’re on the products page that belongs to category cat2.

And so on.