How to set subcategory in Woocommerce?
You will have to first insert the term as required using wp_insert_term. wp_set_object_terms( $post_id, ‘Lense’, ‘product_cat’, false); This function checks if ‘Lense’ term exist in product_cat or not. If does not exist, then create and assign. Check whether term already exists or not $id = term_exists( ‘canon’,’product_cat’,$parent_id ) //$parent_id is parent term id, in your … Read more