I am trying to add some code that will run when an order is opened (which in our case means that status is changed to "PaymentReceived"). I started by looking into adding a handler to the OrderInfo Update.After event. First of all, I have yet to hit my breakpoint on the first line of the handler, which means I'm missing something in the wireup. Second, I can't find any sort of "original object" property of the ObjectEventArgs param, which I would need to verify that the status has in fact changed. Here is the current code:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using CMS.Base; using CMS.DataEngine; using CMS.Ecommerce; public partial class CMSModuleLoader { public class CustomOrderStatusChangeEventHandler : CMSLoaderAttribute { public override void Init() { base.Init(); OrderInfo.TYPEINFO.Events.Update.After += Update_After; } void Update_After(object sender, ObjectEventArgs e) { var order = (OrderInfo)e.Object; var status = OrderStatusInfoProvider.GetOrderStatusInfo(order.OrderStatusID); // how to check if new status is "PaymentReceived" and status has changed? if (status.StatusName == "PaymentReceived") { // Do something. } } } }
Hello, You should use EcommerceEvents
for example: EcommerceEvents.OrderPaid.Execute += OrderPaid_Execute;
Please, sign in to be able to submit a new answer.