is there a possibility to create a new message template, which allows to integrate an individual serial number into the message of a customer after successful payment?
This serial number should be read from a newly created table, which is always filled with serial numbers. When an order is paid, a serial number should be read from the table and sent with an email to the customer. The previously read serial number should then be removed from the table so that it can no longer be reused.
I would appreciate your help very much.
yes you can create a new message template
then you could edit Libraries\Nop.Services\Messages\MessageTokenProvider.cs
and create a new token that reads the serial number from the table
Many, many thanks for your help!
I have already seen this plugin (https://github.com/kfoubert/nopcommerce/blob/master/Plugins/CustomMessageToken/4.1/Nop.Plugin.Misc.CustomToken/Infrastructure/CustomMessageTokenProvider.cs) and tried to implement it. Unfortunately some methods and properties of the classes have changed and I think also the general flow when inserting a new MessageToken. Is there possibly an easier way to insert a MessageToken without directly changing the SourceCode of nopCommerce? How can I even create a MessageToken that accesses the LicenseDownloadId (this attribute is in OrderItem and not in Order).
My approach now is the following:
1. Create a new table, which contains the license keys/serial keys (here I would have thought of using FluentMigrator in the Up() method, which, as I understood, is called during the first installation) - this table is then populated with already generated license keys (externally via SQL Server Management Studio, for example).
2. Creation of a MessageToken for the license key integration into the eMail.
3. As you already suggested, I will now use the OrderPaidEvent to read a license key from the newly created table and then insert it into the LicenseDownloadId table (OrderItem) and Download (the actual license file). Would anyone have a suitable tutorial for the current version where you can see how to access the database and how to insert new data?
What do you think about this approach?
The shipping plugin for Fixed By Weight By Total can be used as an example of a plugin having its own DB table.