How add body_class from wp_termmeta

  • First check it is product category archive page using is_tax
  • Then use get queried object_id to get the current term ID
  • Then after you can use get_term_meta to get class name.

Example:

add_filter( 'body_class', 'lalka_custom_taxonomy_in_body_class' );
function lalka_custom_taxonomy_in_body_class( $classes ){
    if (is_tax('product_cat')) {

        $custom_class = !empty( get_queried_object_id() ) ? get_term_meta(get_queried_object_id(), 'custom-class', true) : FALSE;
        if ( !empty($custom_class) ) {
            $classes[] = 'custom-tax-' . $custom_class;
        }

    }
      return $classes;
}