facetwp change product category termlink

<?php
/** make product category links, shop with product category facet selected **/

add_filter( 'term_link', function( $termlink, $term, $taxonomy ) {
    if ( 'product_cat' == $taxonomy ) {
        $termlink = trailingslashit( get_permalink( wc_get_page_id( 'shop' ) ) ) . '?fwp_product_category=' . $term->slug;
    }
    return $termlink;
}, 10, 3);