Different templates for different product categories WooCommerce?

Need to make a different menu in the sidebar for different category on WooCommerce.

For example:

Page categories of goods No. 1

the <ul>
 the <li>Item 1</li>
 the <li>Item 2</li>
</ul>


Page product category No. 2

the <ul>
 the <li>Item 3</li>
 the <li>Item 4</li>
</ul>


Or just like to make different templates, and menus for each insert is not a problem.
July 4th 19 at 23:42
3 answers
July 4th 19 at 23:44
You can check the category and bring need to her sidebar. If you category more, you can use elseif.

global $post;

$tags = get_the_terms( $post->ID, 'product_cat' );

foreach ( $tags as $tag ) $tags[] = $tag->slug;

if ( in_array( 'cat-name', $tags )) {
dynamic_sidebar( 'cat-name-sidebar' );
}
else {
dynamic_sidebar( 'other-sidebar' );
}

?>
July 4th 19 at 23:46
Different categories needs to be unique classes applied to elements. It is necessary to investigate items of interest in the browser and realize just how unique the class is applied to a certain category depending on the active, then register for these classes styles. The difficulty is to understand which class applies to items depending on the category, since in the generated html markup Wordpress assigns multiCLASS.
July 4th 19 at 23:48
There are plugins which allows you to configure widgets to appear only on certain pages, such as Dynamic Widgets or Widget Logic. If they don't fit, then you can look like them in the plugins directory.

Find more questions by tags JavaScriptjQueryPHPWooCommerceWordPress