How to handle OrderInfo change events (particularly status)?

Keith Donnell asked on November 3, 2015 23:37

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()

            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.

Correct Answer

Dawid Jachnik answered on November 4, 2015 09:15

Hello, You should use EcommerceEvents

for example: EcommerceEvents.OrderPaid.Execute += OrderPaid_Execute;

1 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.