Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Loading...
ARCHIVED This content is retired and no longer maintained. See the latest version here.

Recommended reading 

PriceType examples

This document provides some basic examples of how to use the EPiServer Commerce APIs to work with PriceType features. Examples covered here are for instance how to get price types definitions.

Examples

Adding custom price types

You can add a new line within the SalePriceTypes section in the ecf.catalog.config file, this will make a new Price Type to be added to the system.

<SalePriceTypes>
<add key="NewCustomPriceType" value="3" description="New Custom Price Type" />
<add key="JurisdictionGroup" value="4" description="Jurisdiction Group"/>
</SalePriceTypes>

Note that the value needs to be unique and it must be greater or equal to 3.

Getting all price types - enum and configuration

PriceTypeConfiguration.PriceTypeDefinitions returns all price types - including predefined price types and price types that were defined in configuration.

namespace CodeSamples.Mediachase.Commerce.Pricing
{
public class PriceTypeConfigurationSample
{
#region GetPriceTypeFromEnumAndConfiguration
public IDictionary<CustomerPricing.PriceType, PriceTypeDefinition> GetAllPriceTypeDefinitions()
{
// Get all price types - included predefined and price types from configuration file.
var priceTypeDefinitions = PriceTypeConfiguration.Instance.PriceTypeDefinitions; return priceTypeDefinitions;
}
#endregion
}
}

See also

Do you find this information helpful? Please log in to provide feedback.

Last updated: Oct 21, 2014

Recommended reading