I use below code to add one product category to a product which is added database;
wp_set_object_terms( $the_post_id, 528, 'product_cat' );
and it appends the relevant product category to that post (I can see the category name on products page). But when I tried to do it with and submit form, it only creates and appends as number like 528 (I see the 528 on product page instead of category name);
$kategori = $_POST['kategori'];
wp_set_object_terms( $the_post_id, $kategori, 'product_cat' );
How can I add these all categories if it should be in parent categories also with a submit form?