WordPress wp_set_object_terms does not assign product to custom taxonomy

I can see few potential issues here:

  1. wp_insert_post returns post_id or 0 or WP_Error, if you will have WP_Error it will still pass the if ( $porduct_id ). So here you have one potential issue.

  2. In description you wrote, that you create fields called “regions”, and in code you have wp_set_object_terms($product_id, $regionId, 'region'); so here we have “region” no “regions”. Not sure if you misspelled in the code or in the description.

  3. Last thing is here: <option value="<?php echo $child_category->term_taxonomy_id; ?>" probably it should be $child_category->term_id

Hope any of this will point you to the issue.