If anyone from Shopify monitors this, please address this issue. I track commissions by discount code. We should be able to edit the order, input the discount code. And refund the code savings all in one transaction. We need the ability to add this after the sale. PLEASE.
Your method works but it's easily prone to error when the product price is changed. If there is a negative discount, the order edit will stop working.
When one of the items is already on the order, Shopify doesn't allow you to add more of this item to the order. But it's possible via Shopify admin. I've opened a thread here.
Also, there will be rounding errors:
1. when you allocate a discount to several products
2. discount recalculation
The rounding errors will cause an outstanding balance on the order invoice.