Thanks for your reply, it got me thinking, and I rewrote my file differently and now it works.
But I have a new question how to get the id of a term with its name, I’m trying to use the get the term function:
$ id = get_term_by ($ myslug, $ myterm-name, ‘product_cat’);
but I get nothing:
var_dump ($ id) = false
Thank you