Function to Set Product type in Woocommerce [closed]

I am trying to add a subscription product with custom function in WooCommerce. I am able to add a simple product along with the post_meta, but unable to set the product_type for that product.

Does anyone know the function for saving product_type in WooCommerce?

3 Answers
3

I figured this out, to set the product_type, instead of using update_post_meta(), you use:

wp_set_object_terms( $productID, ‘subscription’, ‘product_type’ );

Leave a Comment