Customizing creation of new customers

In Xperience, you can customize how the system creates new customers. This is suitable especially when you want to process additional actions during the creation of a new customer, or when you want to replace the custom creation process completely.

To customize creating of new customers, you need to implement a class that inherits from the CustomerInfoProvider class:

  1. Prepare an assembly (Class Library project) with class discovery enabled in your Xperience solution (or use an existing one). See Adding custom assemblies

    • Reference the project from both your live site and Xperience administration (CMSApp) projects.
  2. Create a new class in your project in Visual Studio (for example CustomCustomerInfoProvider.cs) that inherits from the CustomerInfoProvider class and registers the custom InfoProvider:

     [assembly: RegisterCustomProvider(typeof(CustomCustomerInfoProvider))]
     public class CustomCustomerInfoProvider : CustomerInfoProvider
  3. Override the default Set method.

  4. Save your project and reload your Xperience website.

The system now uses the custom CustomerInfoProvider class with the modified method.

Example – Adding extra credit to newly registered customers

This example demonstrates adding extra credit to the credit account of every newly registered customer.

using System;

using CMS;
using CMS.Ecommerce;
using CMS.SiteProvider;

[assembly: RegisterCustomProvider(typeof(CustomCustomerInfoProvider))]

public class CustomCustomerInfoProvider : CustomerInfoProvider
    public override void Set(CustomerInfo info)
        if (info == null)
            throw new ArgumentNullException(nameof(info));

        // Indicates whether the set object is a new customer
        bool newCustomer = info.CustomerID <= 0;         

        // Updates or creates the customer based on the default process

        // Adds extra credit for each new registered customer
        if (newCustomer && info.CustomerIsRegistered)
            // Creates a new credit event object
            CreditEventInfo extraCredit = new CreditEventInfo();

            // Sets the credit event's general properties
            extraCredit.EventName = "Extra credit for a new customer";
            extraCredit.EventDate = DateTime.Now;
            extraCredit.EventDescription = "This is starting credit for a new customer.";
            extraCredit.EventCustomerID = info.CustomerID;

            // Sets the credit event's value in the site's main currency
            extraCredit.EventCreditChange = 100;

            // Sets the credit as site or global credit according to the current site's settings
            extraCredit.EventSiteID = ECommerceHelper.GetSiteID(SiteContext.CurrentSiteID, ECommerceSettings.USE_GLOBAL_CREDIT);

            // Saves the credit event to the database