I’m trying to create product with grouped & variable type but It’s not working when I try
$result=wp_set_object_terms( $product_id, 'variable', 'product_type', false );
It shows me invalid taxonomy error and is not inserting the product_type into the database and so is not setting the product type.
I have to update or insert my product_type just as it does in admin from add product option.
Please help with this.thanks in advance.
I got the solution that I have to register the taxonomy as
in my function(user-defined) in function.php before calling
So it create product type as I pass as grouped/variable/external/simple.
Check given example:
I think you’ve written the code directly without using an action.
Try this,
I hope this helps