Class PriceHelper
- Namespace
- Dynamicweb.Ecommerce.Prices
- Assembly
- Dynamicweb.Ecommerce.dll
PriceHelper class. This class cannot be inherited.
public static class PriceHelper
- Inheritance
-
PriceHelper
- Inherited Members
Remarks
Every member here delegates to a service resolved from the dependency container. Prefer injecting Dynamicweb.Ecommerce.Prices.PriceHelper.PriceCalculator over calling this.
Properties
PricesInDatabaseIncludeVat
Gets a value indicating whether prices in the database include VAT.
public static bool PricesInDatabaseIncludeVat { get; }
Property Value
- bool
trueif prices in the database include VAT; otherwise,false.
SystemVat
Gets the system VAT.
public static double SystemVat { get; }
Property Value
- double
System VAT.
Remarks
This is the VAT percent on prices in database.
Methods
ConvertToPIP(Currency?, double)
Converts the given amount to a value in the smallest monitary unit for the given Currency. If the currency doesn't have a culture, it's assumed that the currency uses 2 decimals.
public static long ConvertToPIP(Currency? currency, double amount)
Parameters
currencyCurrencyThe currency that is used to determine the smallest monitary unit.
amountdoubleThe amount to convert to PIP.
Returns
- long
The converted amount in PIP.
Round(Currency?, double)
Rounds the given price to the number of decimals the given Currency uses.
public static double Round(Currency? currency, double price)
Parameters
currencyCurrencyThe currency that is used to determine the number of decimals.
pricedoubleThe price to round.
Returns
- double
The rounded price.
Round(int, double)
Rounds the given price to the given number of decimals.
public static double Round(int decimalDigits, double price)
Parameters
Returns
- double
The rounded price.
ShowPrice(Price, PriceContext, Product, bool)
Check if a price should be shown in a list of prices in a given context. Same as FindPrice(PriceContext, PriceProductSelection) that finds the right price, except it does not check for quantity, units and stock location.
public static bool ShowPrice(Price price, PriceContext context, Product product, bool isInformative)
Parameters
pricePriceThe price.
contextPriceContextThe price context.
productProductThe product.
isInformativeboolif set to
true[is informative].
Returns
- bool
trueif the price should be shown,falseotherwise.