Regenerate Woocommerce Download Permissions

We recently imported a large number of orders and files from and older legacy / custom Ecommerce site into a Woocommerce site.

There are a lot of tales to tell in this adventure, but a big one was getting all of these files attached correctly to the product variations downloadable file.

It took a while to find a good solution, but thankfully Chris Hawkins had a good answer for me over on Stack Overflow.

Here is essentially what my solution looked like:

This only needs to be run once for each order so this can be run from almost anywhere. Make sure to update your offset until you make it through all your orders AND that you already have all your files in place.

That is it! I hope this helps someone!