How to set subcategory in Woocommerce?

Question

Hello I wanna to ask how can we set a sub category of a post in wordpress programatically?

wp_set_object_terms( $post_id, 'Lense', 'product_cat', false);
wp_set_object_terms( $post_id, 'Canon', 'product_cat', true);

But what it does is not setting the parent and child category it set as both parent category

0
Yves Gonzaga 1 year 2020-07-22T15:10:53-05:00 0 Answers 53 views 0

Leave an answer

Browse
Browse