Add body class to category with all its subcategories | Woocommerce
<p>I want to add class to the body tag when viewing a category and all its subcategories, the code bellow work but it just add the class to the category in question but not all its subcategories:</p>

<pre><code>add_filter( 'body_class','custom_body_class' );
function custom_body_class( $classes ) {

    if ( is_product_category( 802 ) ) {
        $classes[] = 'class1';
    } else if ( is_product_category( array( 'femme', 'homme', 'enfant' ) ) ) {
        $classes[] = 'class2';
    }

    return $classes;

}
</code></pre>

<p>I tried to replace <code>is_product_category</code> with <code>in_category</code> or is_product_tag but It does not work either.</p>

<p>Any help would be appreciated.</p>