Programatticaly create a WooCommerce product variation with variations

Stil a work in progress, but I found it hard to get good examples. If you are stuck in creating your script good chance my script gives you hints.

first you create a product if it does not exist. In the loop where I am using it I have the $plugin->name available for the product title.

The above sets $product to the product both when it is new and when it exists.
Now we need to check if a variation exists with the attribute (versie) value which
I have available in $plugin->version

The things you have to replace are ‘versie’, ‘Versie’, $plugin->name and $plugin->version.
These are custom for the ettribute I want to fill