How to change $license->product_id? I've setup a Drupal Commerce site selling licensed roles per instructions on https://www.drupal.org/node/2039687 The same pages says:


  The customer receives the role referenced by the purchased license
  product. Changing $license->product_id (from "Basic Membership" to
  "Premium Membership", for instance) changes the owner's role.


However, it is unclear how to change the $license->product_id. Can anyone clarify can this be done in some kind of UI or rule, or if it should be done in custom module then which hook to use?
I'm not sure there is an easy answer to this right now. Product IDs are updated on licenses when a line item is created or updated. This happens in commerce_license_commerce_line_item_presave().

This gets complicated if you're using Commerce License Billing because your order renews according to your billing arrangement. If you are using that, then you'll need to review the code in there and figure out a way to save a new order that will be the one that gets renewed.

Otherwise, you could just create a new order, set the correct product, revoke the old license, and then complete the new order and then a user will have a new license and the old one will be gone.

If you have more questions, the issue queue is probably the best place to get help and provide feedback.