Basically I'm trying to add a new bookable product in Woocommerce using a custom form I've made, so I have to add the products programmatically. Creating the product is fine, the problem is that I can't figure out how to add a new person type to my product so I can fix multiple prices.
Does someone have an idea how to do this?
This is the code I have so far.
$post_id = wp_insert_post( array(
'post_title' => $_POST["title"],
'post_content' => $_POST["description"],
'post_status' => 'publish',
'post_type' => "product",
) );
wp_set_object_terms( $post_id, 'booking', 'product_type' );
The following will enable "has persons" and create your person types for a bookable product:
Tested and works.