if( has_term( 4, 'product_cat' ) ) { // do something if current product in the loop is in product category with ID 4 }