Skip to main content
2 of 2
Added code markup

You could wipe all terms from a product using the wp_set_post_terms function. Setting the append argument to false ensures that all terms are overwritten.

For example:

wp_set_post_terms( $product_id, array(), 'product_cat', false );

More information on the wp_set_post_terms function: https://developer.wordpress.org/reference/functions/wp_set_post_terms/