Skip to content

Instantly share code, notes, and snippets.

@raphaelchaib
Created August 13, 2014 16:25
Show Gist options
  • Save raphaelchaib/a1a6420c8a150b763004 to your computer and use it in GitHub Desktop.
Save raphaelchaib/a1a6420c8a150b763004 to your computer and use it in GitHub Desktop.
WooCommerce / Javascript: This code transform the WooCommerce Categories List Widget in an accordion.
jQuery(document).ready(function($) {
$(".widget .product-categories > li > .children li").each(function() {
if($(this).has(".children")) {
if(!($(this).hasClass("current-cat-parent"))) {
$(this).find(".children").first().attr("style", "display:none;")
.siblings("a").attr("href", "javascript:void(0);");
}
}
});
$(".widget .product-categories > li > .children li a").click(function() {
$(this).siblings(".children").first().toggle(300);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment