A WooCommerce product is getting created easily but the product is getting added to the product_type:simple. I want to add the product to the "custom product_type:test"
static function createTicket($postId, $productDetails) {
$id = wp_insert_post(array(
'post_type' => 'product',
'post_title' => $productDetails['title'],
'post_content' => $productDetails['description'],
'post_status' => get_post_status($postId),
'max_value' => 1,
));
update_post_meta($id, '_price', $productDetails['price']);
update_post_meta($id, '_regular_price', $productDetails['price']);
update_post_meta($id, '_wpws_testID', $postId);
update_post_meta($id, '_sold_individually', "yes");
wp_set_object_terms( $id, 'test', 'product_type' );
return $id;
}
I have added
wp_set_object_terms( $id, 'test', 'product_type' );
But nothing works
