raise event line should be before #region Notifications & notes
Reason : if I consume OrderPlacedEvent in my plugin and want to add new order token from the Plugin, which can be used in the Email Template. I can not do it. Because Emails are send before OrderPlacedEvent.
This event should not be moved before notifications. It's better to add one more event for such purposes.
But why don't you want to create one more service class derived from TokenProviderService (e.g. CustomTokenProviderService). Then you can override this certain token filling method and add your custom tokens. And then you can register and use it instead of the default TokenProviderService. So CustomTokenProviderService will always be used instead of the TokenProviderService. Not just before order placed event.
This event should not be moved before notifications. It's better to add one more event for such purposes.
But why don't you want to create one more service class derived from TokenProviderService (e.g. CustomTokenProviderService). Then you can override this certain token filling method and add your custom tokens. And then you can register and use it instead of the default TokenProviderService. So CustomTokenProviderService will always be used instead of the TokenProviderService. Not just before order placed event.
I agree for adding new event will be good aproach.
If I understand correctly you want to generate an invoice number when the order is placed and add the invoice number in the order placed email?
If you want to do this with minimal overrides you could do as followed:
- disable the default order placed template and add an extra mail template ( i.e. OrderPlacedWithInvoice ) This way the default nopCommerce orderplaced email won't be sent out.
- consume the orderplaced event, add your custom invoice and send the mail using your custom OrderPlacedWithInvoice template
- use the CustomTokenProviderService to insert the invoice number in the mail using your own custom message token.