I'm trying to create a product in php with variations. I've gotten the product creation but I can't seem to figure out how to create variations for it. Googling only returns adding variations to existing products, but I'm trying to create a product completely from scratch, give it an attribute, and using that attribute to make variations from an array of strings.
$team = get_post();
$post_id = wp_insert_post(
array( 'post_title' => $team->post_title,
'post_type' => 'product',
'post_status' => 'publish'
)
);
wp_set_object_terms( $post_id, 'simple', 'variable' );
update_post_meta( $post_id, '_sku', 'FEES-'.$team->ID );
This is what I have so far.