Individual persistent property per item in stock This is more advanced: We want to sell activation keys for digital products. We know that in Craft a variant has a stock. So every single item "in" the stock needs a unique activation key. When we sell one item of the stock we sell a activation key. Of course, an activation key can only be sold once. For each product we will have a limited number of activation keys, so this will be reflected by the stock number itself. 

We know that this feature requires some customization. Question is: is this achievable in an easy or hard way via Craft Commerce? How would an elegant approach look like?
You can use the beforeGenerateLicenseKey event and query for a custom key in your custom table and set the license key

Event::on(License::class, License::EVENT_GENERATE_LICENSE_KEY, function(GenerateKeyEvent $e) {
    $licenseKey = (new Query())
                      -&gt;select(['mykey'])
                      -&gt;from('{{%mytable}}')
                      -&gt;where(['used' =&gt; false])
                      -&gt;scalar();

    $e-&gt;licenseKey = $licenseKey;
});


And when you insert new keys in your custom DB table, you can change the stock of your variant accordingly

$variant = //grab the variant you need for your product
$variant-&gt;stock = (new Query())-&gt;from('mytable')-&gt;count();
// store the variant