master branch of WooCommerce on Githubcode example:
wp_set_object_terms( $object->get_id(), $data['e_product_type'], 'e_product_type' );
When I follow those steps, I see...
...no term set for a new product, but the correct term set when updating an existing product
I was expecting to see...
...a term set for new as well as updated products
use wp_set_object_terms with
woocommerce_product_import_pre_insert_product_objectwhen importing A NEW product (for assigning a custom taxonomy term to a new product)
The product hasn't been saved at this point, so there is going to be no post ID for new products. You gotta have a post ID for wp_set_object_terms to work. :)
Use the action right under it: woocommerce_product_import_inserted_product_object
Most helpful comment
The product hasn't been saved at this point, so there is going to be no post ID for new products. You gotta have a post ID for
wp_set_object_termsto work. :)Use the action right under it:
woocommerce_product_import_inserted_product_object