I don’t obviously expect someone to write this for me, but can someone give me a semi-detailed explanation of the files and approach to do something as simple as this???
I have been trying to figure this out for 2 days. The idea here is just that some of our products should create a simple license key on checkout and send that key to a 3rd party system.
This is the task at hand:
-
Add a new table into the database called license_keys with the following fields: customer_id, transaction_id, license_key, and transaction_notes
-
Add a new checkbox when configuring a product called is_licensed_product.
-
If this checkbox=yes then:
a. during checkout, magento generates a random alphanumeric key in this format ########-######## where # is a capital letter or a number.
b. this is generated for EACH line item.
c. this is stored in the licence_keys db table along with the transaction_id, etc.
d. an API call is made to a remote server: test.com/recieve?key=12345&email={email}&transaction_id={transaction_id}&customer_id={customer_id}&license_key={license_key}
e. for each lineitem, this API will be called, so that each individual license is sent there. -
This information should then be visible:
a. in the admin system
b. on the receipt sent to the client
c. on the checkout page -
a) When the license key is generated, b) when an API call is made, and c) when the API response is received, all of this information should also put into a array and put into the transaction_notes in the db.
There are many, many, many ways to do this. It’s likely that an observer would be useful, perhaps on
sales_order_place_after[link], which you could use to do some post-processing.In your observer, grab the just-placed order object, look for your license-keyed products, generate the keys, do the inserts, possibly reach out to your API or queue it (be careful about handling slow- or non-responding remote system).
For an example of the core using this event to perform some post-processing of sales rule usage, see Mage_SalesRule_Model_Observer::sales_order_afterPlace() [link].