I use this function to convert the woocommerce category id into a category slug
function woocommerceCategorySlug($id){
$term = get_term( $id, \'product_c
The working solution for this is to use WordPress native function get_term_by()
and to transpose it in your code this way:
function woocommerceCategorySlug( $id ){
$term = get_term_by('id', $id, 'product_cat', 'ARRAY_A');
return $term['slug'];
}
Reference: