Sorry if this has asked already, I did use the search function and it didn't turn up anything.
We are looking to sell a product that we will need to automatically provision on a remote system after checkout. We have the code to provision the product, but I was wondering where the best place to execute that code will be.
We would need access to the previously completed order and be able to determine by sku if the system needs to provision or not. We would also want to use the users email address as the unique id for that product.
There's not much documentation beyond what's in that thread I'm afraid.
You create a DLL project, add a reference to that project to the Nop solution, and write your event handler (static). Attach the event handler per that thread in global.asax. You'll want the OrderCompleted event or patch your files per Andrei's recent posts and create an OrderPaid handler.
The beauty of doing it that way is that the only NopCommerce code you need to change is global.asax. This will make your upgrade path easier. By all means hook into the order process as you suggest if that works better for you.
If you pull this off, could you post a rough outline of the process? I'll be needing to do this soon myself, and would love to see a recent working example (running 1.8, I hope).
Open Nop solution. Add a new DLL project. Right click on that project in solution explorer and add a reference to the business logic DLL project.
Right click on the NopCommerceStore project in solution explorer and add a reference to the new DLL project.
Open up EventContext.cs in the business logic DLL and see which event you want to use.
In the new DLL add a static class with a static function to handle the event. Example:
public static class FleetObserverLiteNopCommercePlugin { /// <summary> /// OrderPlaced event handler /// </summary> /// <remarks>Needs to be threadsafe</remarks> public static void OrderPaidHandler(object sender, OrderEventArgs e) { .... do stuff }