How do I check if a post has a term with a particular ancestor/parent?

It sounds like you’re looking for get_ancestors(). In your case, something like get_ancestors( $term_id, 'product_cat', 'taxonomy' ); should get an array of ancestor (parent, grandparent, etc) IDs for a given $term_id.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)