I created a custom product type if this product type is chosen by the vendor I would like to prefill the product addons settings.
I managed it already for the WordPress frontend, but I can’t manipulate the wcfm product to have the required meta_data.
Here is my code:
if ( 'auto-draft' === get_post_status( $post_ID ) && get_post_type( $post_ID ) == 'product' ) {
if ( wc_get_product( $post_ID ) ) {
//@formatter:off
$data = unserialize('a:1:{....}');
add_post_meta( $post_ID, '_product_addons', $data, false );
add_post_meta( $post_ID, '_product_addons_exclude_global', '1');
//@formatter:on
}
}
The post when creating a a product via the wcfm is not the actual product is a page so it won’t work.
Is there a way to prefill the post_meta with content for the product template?