it may have something to do with WC and this may not be returning what I think it should be returning
$queried_object = get_queried_object();
$taxonomy = $queried_object->taxonomy;
$term_id = $queried_object->term_id;
I don’t know how to test this. Taxonomy should be ‘product_cat’ (i think that the WC taxonomy name) and term_id should be the id of the category.