Table of Contents

Class PriceProvider

Namespace
Dynamicweb.Ecommerce.Prices
Assembly
Dynamicweb.Ecommerce.dll
Represents a price provider.
public class PriceProvider
Inheritance
PriceProvider
Inherited Members

Examples

using System.Collections.Generic;
using Dynamicweb.Ecommerce.Prices;

namespace Dynamicweb.Ecommerce.Examples.Prices
{
    public class PriceProviderSample : PriceProvider
	{
        public override PriceRaw FindPrice(PriceContext context, PriceProductSelection selection)
        {
			// Get the price from the DefaultPriceProvider
			DefaultPriceProvider defaultProvider = new DefaultPriceProvider();
			PriceRaw customPrice = defaultProvider.FindPrice(context, selection);

			//find your own price
			if (context.Customer != null && context.Customer.CustomerNumber.StartsWith("abc"))
			{
				customPrice.Price *= .90;
				return customPrice;
			}
			else if (selection.Quantity > 1)
			{
				customPrice.Price *= .95;
				return customPrice;
			}

			return customPrice;
		}

#if DW10
        public override PriceRaw FindInformativePrice(PriceContext context, PriceProductSelection selection)
        {
            throw new System.NotImplementedException();
        }

        public override void PreparePrices(PriceContext context, IEnumerable<PriceProductSelection> selections)
        {
            throw new System.NotImplementedException();
        }
#endif
    }
}

Properties

HandlePricesExclusively

Property indicating whether this PriceProvider handles all prices.
public virtual bool HandlePricesExclusively { get; }

Property Value

bool
Boolean value indicating whether this PriceProvider handles all prices. DefaultPriceProvider will become disabled if true is returned.

Remarks

Returning true will cause DefaultPriceProvider to become disabled. Default value is false.

Methods

FindInformativePrice(PriceContext, PriceProductSelection)

Finds the informative price. Must be overriden.
public virtual PriceRaw FindInformativePrice(PriceContext context, PriceProductSelection selection)

Parameters

context PriceContext
Context information.
selection PriceProductSelection
Product information.

Returns

PriceRaw
An instance of PriceRaw

FindInformativePrice(Product, double, string, Currency, string, User)

Finds the informative price. Must be overriden.
[Obsolete("Use overload with PriceContext")]
public virtual PriceRaw FindInformativePrice(Product product, double quantity, string variantId, Currency currency, string unitId, User user)

Parameters

product Product
The product to find the price for.
quantity double
The quantity - usually 1, but if the product comes from an order or cart it can be higher. See remarks.
variantId string
The variant id of the current product.
currency Currency
The currency in which the price is required.
unitId string
The unit id of the product.
user User
The user for whom the price is valid for.

Returns

PriceRaw
The PriceRaw.

FindInformativePrice(Product, double, string, Currency, string, User, string)

Finds the informative price. Must be overriden.
[Obsolete("Use overload with PriceContext")]
public virtual PriceRaw FindInformativePrice(Product product, double quantity, string variantId, Currency currency, string unitId, User user, string shopId)

Parameters

product Product
The product to find the price for.
quantity double
The quantity - usually 1, but if the product comes from an order or cart it can be higher. See remarks.
variantId string
The variant id of the current product.
currency Currency
The currency in which the price is required.
unitId string
The unit id of the product.
user User
The user for whom the price is valid for.
shopId string
The shop id for whom the price is valid for.

Returns

PriceRaw
The PriceRaw.

FindInformativePrice(Product, double, string, Currency, string, User, string, StockLocation)

Finds the informative price. Must be overriden.
[Obsolete("Use overload with PriceContext")]
public virtual PriceRaw FindInformativePrice(Product product, double quantity, string variantId, Currency currency, string unitId, User user, string shopId, StockLocation stockLocation)

Parameters

product Product
The product to find the price for.
quantity double
The quantity - usually 1, but if the product comes from an order or cart it can be higher. See remarks.
variantId string
The variant id of the current product.
currency Currency
The currency in which the price is required.
unitId string
The unit id of the product.
user User
The user for whom the price is valid for.
shopId string
The shop id for whom the price is valid for.
stockLocation StockLocation
The stock location.

Returns

PriceRaw
The PriceRaw.

FindPrice(PriceContext, PriceProductSelection)

Finds the price for a given product in a given context. Can be called to show the price of a product, show the price of a product for a specific user, unit etc. Must be overriden.
public virtual PriceRaw FindPrice(PriceContext context, PriceProductSelection selection)

Parameters

context PriceContext
Context information.
selection PriceProductSelection
Product information.

Returns

PriceRaw
An instance of PriceRaw

Remarks

This method is called in 2 contexts. For showing a product and a product added to a cart or order. If the call comes from an order object, it can have a quantity of 2 or more and can be used to return the unit price for a product that is cheaper if more than one is bought

FindPrice(Product, double, string, Currency, string, User)

Finds the price for a given product in a given context. Can be called to show the price of a product, show the price of a product for a specific user, unit etc. Must be overriden.
[Obsolete("Use overload with PriceContext")]
public virtual PriceRaw FindPrice(Product product, double quantity, string variantId, Currency currency, string unitId, User user)

Parameters

product Product
The product to find the price for.
quantity double
The quantity - usually 1, but if the product comes from an order or cart it can be higher. See remarks.
variantId string
The variant id of the current product.
currency Currency
The currency in which the price is required.
unitId string
The unit id of the product.
user User
The user for whom the price is valid for.

Returns

PriceRaw
The PriceRaw.

Remarks

This method is called in 2 contexts. For showing a product and a product added to a cart or order. If the call comes from an order object, it can have a quantity of 2 or more and can be used to return the unit price for a product that is cheaper if more than one is bought

FindPrice(Product, double, string, Currency, string, User, double)

Finds the price for a given product in a given context. Can be called to show the price of a product, show the price of a product for a specific user, unit etc. Must be overriden.
[Obsolete("Use overload with PriceContext")]
public virtual PriceRaw FindPrice(Product product, double quantity, string variantId, Currency currency, string unitId, User user, double quantityAllVariants)

Parameters

product Product
The product to find the price for.
quantity double
The quantity - usually 1, but if the product comes from an order or cart it can be higher. See remarks.
variantId string
The variant id of the current product.
currency Currency
The currency in which the price is required.
unitId string
The unit id of the product.
user User
The user for whom the price is valid for.
quantityAllVariants double
The quantity of all variants.

Returns

PriceRaw
The PriceRaw.

Remarks

This method is called in 2 contexts. For showing a product and a product added to a cart or order. If the call comes from an order object, it can have a quantity of 2 or more and can be used to return the unit price for a product that is cheaper if more than one is bought

FindPrice(Product, double, string, Currency, string, User, double, string)

Finds the price for a given product in a given context. Can be called to show the price of a product, show the price of a product for a specific user, unit etc. Must be overriden.
[Obsolete("Use overload with PriceContext")]
public virtual PriceRaw FindPrice(Product product, double quantity, string variantId, Currency currency, string unitId, User user, double quantityAllVariants, string shopId)

Parameters

product Product
The product to find the price for.
quantity double
The quantity - usually 1, but if the product comes from an order or cart it can be higher. See remarks.
variantId string
The variant id of the current product.
currency Currency
The currency in which the price is required.
unitId string
The unit id of the product.
user User
The user for whom the price is valid for.
quantityAllVariants double
The quantity of all variants.
shopId string
The shop id for whom the price is valid for.

Returns

PriceRaw
The PriceRaw.

Remarks

This method is called in 2 contexts. For showing a product and a product added to a cart or order. If the call comes from an order object, it can have a quantity of 2 or more and can be used to return the unit price for a product that is cheaper if more than one is bought

FindPrice(Product, double, string, Currency, string, User, double, string, StockLocation)

Finds the price for a given product in a given context. Can be called to show the price of a product, show the price of a product for a specific user, unit etc. Must be overriden.
[Obsolete("Use overload with PriceContext")]
public virtual PriceRaw FindPrice(Product product, double quantity, string variantId, Currency currency, string unitId, User user, double quantityAllVariants, string shopId, StockLocation stockLocation)

Parameters

product Product
The product to find the price for.
quantity double
The quantity - usually 1, but if the product comes from an order or cart it can be higher. See remarks.
variantId string
The variant id of the current product.
currency Currency
The currency in which the price is required.
unitId string
The unit id of the product.
user User
The user for whom the price is valid for.
quantityAllVariants double
The quantity of all variants.
shopId string
The shop id for whom the price is valid for.
stockLocation StockLocation
The current stock location.

Returns

PriceRaw
The PriceRaw.

Remarks

This method is called in 2 contexts. For showing a product and a product added to a cart or order. If the call comes from an order object, it can have a quantity of 2 or more and can be used to return the unit price for a product that is cheaper if more than one is bought

PreparePrices(PriceContext, IEnumerable<PriceProductSelection>)

Prepares prices for a collection of products. Must be overriden.
public virtual void PreparePrices(PriceContext context, IEnumerable<PriceProductSelection> selections)

Parameters

context PriceContext
Context information.
selections IEnumerable<PriceProductSelection>
Product selections with a list of products and their quantity in the current cart or order.

Remarks

This method is called before the actual use of each products price. Use this method to find all the prices needed in the upcoming FindPrice calls. This method can be used to retrieve i.e. 30 prices from an ERP system and saved into a cache that is later used by FindPrice.

PreparePrices(ProductCollection)

Prepares the prices for a list of products shown in the frontend - usually a product list or a list of related products, favorites etc. Must be overriden.
[Obsolete("Use overload with PriceContext")]
public virtual void PreparePrices(ProductCollection products)

Parameters

products ProductCollection
The products.

Remarks

This method is called before the actual use of each products price. This method is called once per instance (i.e. showing a list of products) where FindPrice is called once for each product in the list. Use this method to find all the prices needed in the upcoming FindPrice calls. This method can be used to retrieve i.e. 30 prices from an ERP system and saved into a cache that is later used by FindPrice.

PreparePrices(Dictionary<Product, double>)

Prepares prices for a list of products coming from a cart or order context. Must be overriden.
[Obsolete("Use overload with PriceContext")]
public virtual void PreparePrices(Dictionary<Product, double> products)

Parameters

products Dictionary<Product, double>
The products with a list of products and their quantity in the current cart or order.

Remarks

This method is called before the actual use of each products price. This method is called once per instance (i.e. showing a list of orderlines in a cart or order) where FindPrice is called once for each product in the list. Use this method to find all the prices needed in the upcoming FindPrice calls. This method can be used to retrieve i.e. 30 prices from an ERP system and saved into a cache that is later used by FindPrice.

PreparePrices(IEnumerable<Product>)

Prepares the prices for a list of products shown in the frontend - usually a product list or a list of related products, favorites etc. Must be overriden.
[Obsolete("Use overload with PriceContext")]
public virtual void PreparePrices(IEnumerable<Product> products)

Parameters

products IEnumerable<Product>
The products.

Remarks

This method is called before the actual use of each products price. This method is called once per instance (i.e. showing a list of products) where FindPrice is called once for each product in the list. Use this method to find all the prices needed in the upcoming FindPrice calls. This method can be used to retrieve i.e. 30 prices from an ERP system and saved into a cache that is later used by FindPrice.
To top