---
title: Custom Info provider example
related:
  - https://docs.kentico.com/13/custom-development/customizing-providers.md
  - https://docs.kentico.com/13/custom-development/customizing-providers/registering-providers-using-assembly-attributes.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

The system uses Info providers to work with individual types of objects. A provider class contains methods for creating, updating, getting, and deleting the data of the corresponding objects. By customizing the appropriate Info provider, you can change or extend the functionality of nearly any object in the system.

The following example customizes the **OrderInfoProvider**, which the [E-commerce](https://docs.kentico.com/13/e-commerce-features.md) solution uses to manage product [orders](https://docs.kentico.com/13/e-commerce-features/managing-on-line-stores/orders.md). The example adds a custom action when creating orders – for orders that fulfill certain conditions, [credit](https://docs.kentico.com/13/e-commerce-features/configuring-on-line-stores/configuring-payment-methods/configuring-customer-credit.md) is added to the given customer.

You can use the same general approach to customize any standard provider, helper or manager class in Xperience (i.e. those that inherit from the **AbstractInfoProvider**, **AbstractHelper** or **AbstractManager** class respectively).

## Writing the custom provider

Start by preparing a separate project for custom classes in your Xperience solution:

1. Open your Xperience solution in Visual Studio.
2. [Add a custom assembly](https://docs.kentico.com/13/custom-development/adding-custom-assemblies.md) (_Class Library_ project) with class discovery enabled to the solution, or re-use an existing assembly.
3. Reference the project from both your live site project and the Xperience administration project (_CMSApp_).

Continue by implementing the custom provider class:

1. Add a new class under the custom project. For example, name the class _**CustomOrderInfoProvider.cs**_.
2. Modify the class's declaration so that it inherits from the **CMS.Ecommerce.OrderInfoProvider** class.

   > **Info:** Custom providers must always inherit from the original provider class. This ensures that the custom provider supports all of the default functionality and allows you to add your own customizations by overriding the existing members of the class.
3. Override the class's **SetOrderInfoInternal** method.
4. [Register the custom provider](https://docs.kentico.com/13/custom-development/customizing-providers/registering-providers-using-assembly-attributes.md) by adding the **RegisterCustomProvider** assembly attribute above the class declaration (requires a using statement for the **CMS** namespace). The attribute's parameter specifies the type of the custom provider class as a **System.Type** object.

   ```csharp

   using System;

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

   // Registers the custom OrderInfoProvider
   [assembly: RegisterCustomProvider(typeof(CustomOrderInfoProvider))]

   public class CustomOrderInfoProvider : OrderInfoProvider
   {
       /// <summary>
       /// Sets (updates or inserts) the specified order.
       /// </summary>
       public override void Set(OrderInfo info)
       {
           if (info == null)
           {
               throw new ArgumentNullException(nameof(info));
           }

           // Indicates whether the set object is a new order
           bool newOrder = info.OrderID <= 0;

           // Updates the order or creates a new order using the default API of the base class
           base.Set(info);

           // Adds extra credit for each new order with a total price higher than 1000
           if (newOrder && (info.OrderTotalPriceInMainCurrency > 1000))
           {
               // Creates a new credit event
               CreditEventInfo extraCredit = new CreditEventInfo();

               // Sets the credit event's general properties
               extraCredit.EventName = string.Format("Credit for your order: {0}", info.OrderID);
               extraCredit.EventDate = DateTime.Now;
               extraCredit.EventDescription = "Thank you for your order.";
               extraCredit.EventCustomerID = info.OrderCustomerID;

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

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

               // Saves the credit event
               CreditEventInfo.Provider.Set(extraCredit);
           }
       }
   }

   ```
5. Save all changes and **Rebuild** the solution.

The override of the **Set** method ensures that customers who purchase orders with a total price higher than 1000 (in the site's [main currency](https://docs.kentico.com/13/e-commerce-features/configuring-on-line-stores/configuring-currencies.md)) receive extra [customer credit](https://docs.kentico.com/13/e-commerce-features/configuring-on-line-stores/configuring-payment-methods/configuring-customer-credit.md). You can use the same approach to add any other types of custom actions.
