Use this
$product_terms = wp_get_object_terms( 17, 'product_cat', array( 'fields' => 'all' ) );
and then get the parent cat id and move all sub cat into an array.
Use this
$product_terms = wp_get_object_terms( 17, 'product_cat', array( 'fields' => 'all' ) );
and then get the parent cat id and move all sub cat into an array.