---
title: Customizing product prices
related:
  - https://docs.kentico.com/k10/e-commerce-features/managing-your-store/products.md
  - https://docs.kentico.com/k10/e-commerce-features/configuring-your-store/configuring-products.md
  - https://docs.kentico.com/k10/custom-development/customizing-providers.md
  - https://docs.kentico.com/k10/custom-development.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).

In Kentico, you can modify the way of retrieving a [product](https://docs.kentico.com/k10/e-commerce-features/managing-your-store/products.md)'s price. On this page, you can also see [examples](#examples) of product price customization.

To customize retrieving prices, you need to implement a class that inherits from the **SKUInfoProvider** class:

1. Create a new class in your project in Visual Studio (for example **CustomSKUInfoProvider.cs**) that inherits from the **SKUInfoProvider** class and [registers the custom InfoProvider](https://docs.kentico.com/k10/custom-development/customizing-providers/registering-providers-using-assembly-attributes.md):

   ```csharp

   [assembly: RegisterCustomProvider(typeof(CustomSKUInfoProvider))]
   public class CustomSKUInfoProvider : SKUInfoProvider
   {
   }

   ```
2. Implement a method that overrides a default _SKUInfoProvider_ method.
   - See [the list of all price-related virtual methods](#list-of-price-related-virtual-methods-in-the-skuinfoprovider) that you can override.
3. Save your project and reload you Kentico website.

If you open your website, Kentico uses the modified _SKUInfoProvider_ class with the modified methods.

## List of price-related virtual methods in the SKUInfoProvider

### GetSKUPriceInternal

Returns a price of a specified product or product option (_SKUInfo sku_) based on the product's and the shopping cart's data (_ShoppingCartInfo cart_).

You can set whether [discounts](https://docs.kentico.com/k10/e-commerce-features/managing-your-store/discounts.md) and [taxes](https://docs.kentico.com/k10/e-commerce-features/configuring-your-store/configuring-taxes.md) are calculated (_bool discounts_ and _bool taxes_). You can also set whether the system calls the method within a shopping cart calculation, or within displaying the price on the live site (_bool forCart_). You can set which database column the system uses for the price retrieving (_string column_); otherwise, the _SKUPrice_ column is used.

If the SKU is a product option's SKU, you can specify the parent SKU (_SKUInfo parentSku_) for tax and discount calculation. You can also specify a custom price (_double customPrice_) to calculate with a different then the SKU's price.

```csharp

protected virtual double GetSKUPriceInternal(SKUInfo sku, ShoppingCartInfo cart) { }
--OR--
protected virtual double GetSKUPriceInternal(SKUInfo sku, ShoppingCartInfo cart, string column) { }
--OR--
protected virtual double GetSKUPriceInternal(SKUInfo sku, ShoppingCartInfo cart, bool discounts, bool taxes, bool forCart, string column, SKUInfo parentSku = null, double customPrice = Double.NaN) { } 

```

> **Tip:** See examples [below](#examples). 

### GetSKUFormattedPriceInternal

Returns a [formatted price](https://docs.kentico.com/k10/e-commerce-features/getting-familiar-with-the-e-commerce-solution.md#gettingfamiliarwiththeecommercesolution-letterf) of a specified product or product option (_SKUInfo sku_) based on the product's and the shopping cart's (_ShoppingCartInfo cart_) data. Set whether discounts and taxes are calculated (_bool discounts_ and _bool taxes_).

You can set which database column the system uses for the price retrieving (_string column_); otherwise, the _SKUPrice_ column is used.

```csharp

protected virtual string GetSKUFormattedPriceInternal(SKUInfo sku, ShoppingCartInfo cart, bool discounts, bool taxes, string column) { }

```

### CalculateSKUPriceAfterDiscountInternal

Returns a price of a specified product or product option (_SKUInfo sku_) after all its [catalog discounts](https://docs.kentico.com/k10/e-commerce-features/managing-your-store/discounts/working-with-catalog-discounts.md) are applied based on the product's and the shopping cart's _ShoppingCartInfo cart_) data. Set whether the system calls the method within a shopping cart calculation, or within displaying the price on the live site (_bool forCart_).

You can set which database column the system uses for the price retrieving (_string column_); otherwise, the _SKUPrice_ column is used.

If the SKU is a product option's SKU, you can specify the parent SKU (_SKUInfo parentSku_) for tax and discount calculation. You can also specify a custom price (_double customPrice_) to calculate with a different then the SKU's price.

```csharp

protected virtual double CalculateSKUPriceAfterDiscountInternal(SKUInfo sku, ShoppingCartInfo cart, bool forCart, string column, SKUInfo parentSku = null, double customPrice = Double.NaN) { }

```

### CalculateSKUDiscountInternal

Returns an amount of a specified catalog discount (_IItemDiscount_ discount) that is applied to a specified product _(SKUInfo sku_) in a specified shopping cart (_ShoppingCartInfo cart_). By default,  [theCalculateSKUPriceAfterDiscountInternalmethod](#calculateskupriceafterdiscountinternal) calls this method for every catalog discount and therefore, you need to specify the product's price after applying previous discounts (_double priceAfterDiscount_). If there are not any previously applied catalog discounts, you can use the SKU's price.

The method returns the noted price if the amount of the discount is bigger than the price.

```csharp

protected virtual double CalculateSKUDiscountInternal(SKUInfo sku, ShoppingCartInfo cart, IItemDiscount discount, double priceAfterDiscount) { }

```

### CalculateSKUTotalTaxInternal

Returns the total tax amount of a specified product or product option (_SKUInfo sku_) in a specified shopping cart (_ShoppingCartInfo cart_). Specify the price after applying discounts to which taxes apply (_double priceAfterDiscount_).

If the SKU is a product option's SKU, specify the option's parent SKU for tax calculation purposes (_SKUInfo parentSku_).

The result is cached according to the [cache settings](https://docs.kentico.com/k10/configuring-kentico/optimizing-website-performance/configuring-caching/reference-cache-settings.md) (opposed to [theCalculateSKUTotalTaxFromDBInternalmethod](#calculateskutotaltaxfromdbinternal)).

```csharp

protected virtual double CalculateSKUTotalTaxInternal(SKUInfo sku, ShoppingCartInfo cart, double priceAfterDiscount, SKUInfo parentSku = null) { }

```

### CalculateSKUTotalTaxFromDBInternal

Returns the total tax amount of a specified product or product option (_SKUInfo sku_) in a specified shopping cart (_ShoppingCartInfo cart_). Specify the price after applying discounts to which taxes apply (_double priceAfterDiscount_).

If the SKU is a product option's SKU, specify the option's parent SKU for tax calculation purposes (_SKUInfo parentSku_).

The result is not cached (opposed to [theCalculateSKUTotalTaxInternalmethod](#calculateskutotaltaxinternal)).

```csharp

protected virtual double CalculateSKUTotalTaxFromDBInternal(SKUInfo sku, ShoppingCartInfo cart, double priceAfterDiscount, SKUInfo parentSku = null) { } 

```

## Examples

### Getting the product prices based on the visitor's culture

This example demonstrates how to customize the **GetSKUPriceInternal** method to return different prices for different visitors' cultures. The culture is stored among the shopping cart data.

The example uses custom database columns (_SKUEnUsPrice_ and _SKUEnUkPrice_). To add a custom database column:

1. Open the **Modules** application.
2. **Edit** () the _E-commerce_ module.
3. Switch to the **Classes** tab.
4. **Edit** () the _SKU_ class.
5. Switch to the **Fields** tab.
6. [Create a new field](https://docs.kentico.com/k10/custom-development/developing-form-controls/reference-field-editor.md) based on your needs.
7. Click **Save**.

The new database column is ready to use. Repeat the steps to create more columns.

```csharp

using CMS;
using CMS.Ecommerce;
using CMS.Helpers;
using CMS.Base;

[assembly: RegisterCustomProvider(typeof(CustomSKUInfoProvider))]
public class CustomSKUInfoProvider : SKUInfoProvider
{
    protected override double GetSKUPriceInternal(SKUInfo sku, ShoppingCartInfo cart)
    {
        double price = 0;

        // Checks whether the shopping cart data exists.
        if (cart != null)
        {
            // Selects the shopping cart's culture.
            switch (cart.ShoppingCartCulture.ToLowerCSafe())
            {
                case "en-us":
                    // Gets the product's price from the SKUEnUsPrice database column.
                    price = ValidationHelper.GetDouble(sku.GetValue("SKUEnUsPrice"), 0);
                    break;
                case "en-uk":
                    // Gets the product's price from the SKUEnUkPrice database column.
                    price = ValidationHelper.GetDouble(sku.GetValue("SKUEnUkPrice"), 0);
                    break;
            }
        }

        // Checks whether a custom price was assigned.
        if (price == 0)
        {
            // Gets the price from the default SKUPrice database column.
            return base.GetSKUPriceInternal(sku, cart);
        }

        // Returns the custom price.
        return price;
    }
}

```

### Getting the product prices based on the product's public status

This example demonstrates how to customize the **GetSKUPriceInternal** method to return different prices of products that have a specific public product status.

The example uses a custom database column (_SKUDiscountedPrice_). See the [previous example](#getting-the-product-prices-based-on-the-visitors-culture) to see how to add new database columns.

```csharp

using CMS;
using CMS.Ecommerce;
using CMS.Helpers;
using CMS.Base;

[assembly: RegisterCustomProvider(typeof(CustomSKUInfoProvider))]
public class CustomSKUInfoProvider : SKUInfoProvider
{
    protected override double GetSKUPriceInternal(SKUInfo sku, ShoppingCartInfo cart)
    {
        double price = 0;

        // Gets the product's public product status.
        PublicStatusInfo status = PublicStatusInfoProvider.GetPublicStatusInfo(sku.SKUPublicStatusID);

        // Checks whether the product has the 'discounted' status.
        if ((status != null) && (status.PublicStatusName.ToLowerCSafe() == "discounted"))
        {
            // Gets the product's price from a special database column - SKUDiscountedPrice.
            price = ValidationHelper.GetDouble(sku.GetValue("SKUDiscountedPrice"), 0);
        }

        // Checks whether a custom price was assigned.
        if (price == 0)
        {
            // Gets the price from the default SKUPrice database column.
            return base.GetSKUPriceInternal(sku, cart);
        }

        // Returns the custom price.
        return price;
    }
}

```
