I've been pondering how to handle the case where a new order is made to renew a license.
On the one hand, we want the new order to have the same values as the original, and hold an order item for the license product. On the other hand, we don't want our code that creates a new license for this product to kick in!
Given this is going to be an automatic order, it seems to me that the simplest thing is to require whoever creates the order to set the existing license to renew on the order item when they add it to the order.
LicenseOrderSyncSubscriber should then pick up on this, and instead of creating a new license, renew the one it finds.
Comments
Comment #2
joachim commentedThis is obsolete -- see #2908031: change LicenseOrderSyncSubscriber::getOrderItemsWithLicensedProducts() to detect order items, not products.
In fact, if a license is already present on an order item, the sync process should just carry on as if it had just created it. This allows for programmatic creation of licenses to put automatically into the cart, such as a 'buy access to this file' link.
Comment #3
subhojit777Hey @joachim, we have this requirement in one of our project. After reading your comments on this issue, and checking
LicenseOrderSyncSubscriber, this is what I understand is the way to implement license renewal using a new order.load-ed, and attached to a new orderLicenseOrderSyncSubscribertakes care of renewing the licenseCould you please confirm whether I am right. If yes, then I believe points 2 and 4 have to be written in a custom module or something.
Comment #4
subhojit777I followed #3 and they are working. One important point here is - you would have to add a submit callback in `add to cart` form, that is going to attach the expired license to the newly created order item. And
LicenseOrderSyncSubscriberwill take care of everything.