Matt Mason asked on July 24, 2014 23:08

I am trying to Create a new Custom Ecommerce Handler using the TYPEINFO Object Event handler. I am however unable to find the ecommerce object for something like this: += ....

Any ideas of where to look?

Recent Answers

Brenden Kehren answered on July 25, 2014 13:48

Here's the link to the documentation. It walks you through creating a custom handler. If you're using v7, you can check it out here.

0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on July 25, 2014 17:57

From what I understand, the item that you add an event handler to has to be an actual class or object in kentico. For example, you could override the userinfo class by doing Ecommerce isn't a class, but ShippingInfo or ProductInfo are classes.

What specific object do you want to override or handle? Product creation? Order Creation? Shipping?

0 votesVote for this answer Mark as a Correct answer

Matt Mason answered on July 28, 2014 21:51

I wanted to be able to capture the post-order event so I can enter the information into Authorize.Net's Customer Information Manager. This is what I ended up with:

public override void Init() { // Assigns a handler to the Insert.After event for the Ecommerce object type // This event occurs after the creation of every new order CMS.Ecommerce.OrderInfo.TYPEINFO.Events.Insert.After += Insert_After; }

    void Insert_After(object sender, ObjectEventArgs e)
        AuthorizeNet.CustomerGateway gateway = new CustomerGateway("", "", ServiceMode.Test);
        CMS.Ecommerce.OrderInfo orderInfo = (CMS.Ecommerce.OrderInfo)sender;
        int userID = orderInfo.OrderCompletedByUserID;

        CMS.Membership.UserInfo Ui = (CMS.Membership.UserInfo)CMS.Membership.UserRoleInfoProvider.GetInfoById(MembershipInfo.OBJECT_TYPE, userID);

        AuthorizeNet.Customer customer = gateway.GetCustomer(Ui.GetCIMid().ToString());
        if (customer == null)
            //  creating the profile, we add billing address,  shipping address
            customer = gateway.CreateCustomer(Ui.Email, "Auto created " + DateTime.Now.ToString("MMM dd yyyy HH:mm:ss"));
            customer.ID = userID.ToString();
            AuthorizeNet.Address shipping = new AuthorizeNet.Address();
            shipping.City = orderInfo.OrderShippingAddress.AddressCity;
            CMS.Globalization.CountryInfo ciShipping = CMS.Globalization.CountryInfoProvider.GetCountryInfo(orderInfo.OrderShippingAddress.AddressCountryID);
            shipping.Country = ciShipping.CountryDisplayName;
            shipping.Street = orderInfo.OrderShippingAddress.AddressLine1 + ", " + orderInfo.OrderShippingAddress.AddressLine2;
            shipping.Zip = orderInfo.OrderShippingAddress.AddressZip;
            List<AuthorizeNet.Address> sAddys = new List<AuthorizeNet.Address>();
            customer.ShippingAddresses = sAddys;
            AuthorizeNet.Address billing = new AuthorizeNet.Address();

            billing.City = orderInfo.OrderBillingAddress.AddressCity;
            CMS.Globalization.CountryInfo ciBilling = CMS.Globalization.CountryInfoProvider.GetCountryInfo(orderInfo.OrderBillingAddress.AddressCountryID);
            billing.Country = ciBilling.CountryDisplayName;
            billing.Street = orderInfo.OrderBillingAddress.AddressLine1 + "," + orderInfo.OrderBillingAddress.AddressLine2;
            StateInfo si = StateInfoProvider.GetStateInfo(orderInfo.OrderBillingAddress.AddressStateID);
            billing.State = si.StateDisplayName;
            billing.Zip = orderInfo.OrderBillingAddress.AddressZip;
            customer.BillingAddress = billing;
0 votesVote for this answer Mark as a Correct answer

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