jQuery(function($){
// add a new toggle element after the parent category anchor
$( "" ).insertAfter( "#secondary .widget_product_categories .product-categories .cat-item.cat-parent > a" );
// when the new toggle element is clicked, add/remove the class that controls visibility of children
$( "#secondary .widget_product_categories .product-categories .woo-cat-toggle" ).click(function () {
$(this).toggleClass("cat-popped");
});
// if the parent category is the current category or a parent of an active child, then show the children categories too
$('#secondary .widget_product_categories .product-categories .cat-item.cat-parent').each(function(){
if($(this).is('.current-cat, .current-cat-parent')) {
$(this).children('.woo-cat-toggle').toggleClass("cat-popped");
}
});
});
.widget_product_categories ul.product-categories li.cat-parent {
position: relative;
}
.widget_product_categories ul.product-categories li.cat-parent .woo-cat-toggle {
cursor: pointer;
float:right;
display: inline-block;
text-align: center;
margin-left: 0.5em;
width: 1.5em;
line-height: 1em;
-webkit-transform: rotate(-90deg);
transform: rotate(-90deg);
transition: all 0.4s ease;
width: 20px;
height: 20px;
background: rgba(0,0,0,0.05);
text-align: center;
line-height: 18px;
border-radius: 50%;
}
.widget_product_categories ul.product-categories li.cat-parent .woo-cat-toggle.cat-popped {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
background: rgba(85,85,85,0.8);
color: white;
}
.widget_product_categories ul.product-categories li.cat-parent .woo-cat-toggle::before {
font-weight: normal;
font-style: normal;
font-size: 19px;
text-transform: none;
speak: none;
content: '+';
line-height: 20px;
width: 20px;
height: 20px;
text-align: center;
}
.widget_product_categories ul.product-categories li.cat-parent .woo-cat-toggle.cat-popped::before {
content: '\2013';
}
.widget_product_categories ul.product-categories li.cat-parent .woo-cat-toggle ~ ul.children {
overflow: hidden;
max-height: 0;
transition: all 0.4s ease;
}
.widget_product_categories ul.product-categories li.cat-parent .woo-cat-toggle.cat-popped ~ ul.children {
max-height: fit-content;
}













