facetwp use term as css class in layout builder

<?php
/** creates a space seperated list of terms (instead of links) for use in
 ** dynamic tags for outputting a css class
 **/
add_action( 'facetwp_builder_item_value', function( $value, $item ) {
    if ( 'product-categories' == $item['settings']['name'] ) {
        $value = "";
        $terms = wp_get_post_terms( get_the_ID(), 'product_cat' );
        if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) {
            foreach ( $terms AS $term ) {
                $value .= $term->slug . "";
            }
        }
    }
    return $value;
}, 10, 2 );