Class DiscountCollection
- Namespace
- Dynamicweb.Ecommerce.Discounts
- Assembly
- Dynamicweb.Ecommerce.dll
Represents a collection of discounts.
[Obsolete("Sales discount functionality is obsolete. Use Dynamicweb.Ecommerce.Orders.Discounts.* instead.")]
[Serializable]
public sealed class DiscountCollection : Collection<Discount>, IList<Discount>, ICollection<Discount>, IReadOnlyList<Discount>, IReadOnlyCollection<Discount>, IEnumerable<Discount>, IList, ICollection, IEnumerable, IWithPrice
- Inheritance
-
DiscountCollection
- Implements
- Inherited Members
- Extension Methods
Constructors
DiscountCollection(PriceContext, Product, string, long)
Initializes a new instance of the DiscountCollection class.
public DiscountCollection(PriceContext context, Product product, string unitId, long stockLocationId)
Parameters
context
PriceContext- Price context.
product
Product- Product.
unitId
string- Unit identifier.
stockLocationId
long- Stock location identifier.
- See Also
-
Collection<T>
DiscountCollection(Product, Currency, Country)
Initializes a new instance of the DiscountCollection class.
[Obsolete("Use constructor overload which takes a PriceContext")]
public DiscountCollection(Product product, Currency currency, Country country)
Parameters
- See Also
-
Collection<T>
DiscountCollection(Product, Currency, Country, string)
Initializes a new instance of the DiscountCollection class.
[Obsolete("Use constructor overload which takes a PriceContext")]
public DiscountCollection(Product product, Currency currency, Country country, string unitId)
Parameters
product
Product- The product.
currency
Currency- The currency.
country
Country- The country.
unitId
string
- See Also
-
Collection<T>
DiscountCollection(Product, Currency, Country, string, string)
Initializes a new instance of the DiscountCollection class.
[Obsolete("Use constructor overload which takes a PriceContext")]
public DiscountCollection(Product product, Currency currency, Country country, string unitId, string shopId)
Parameters
product
Product- The product.
currency
Currency- The currency.
country
Country- The country.
unitId
stringshopId
string
- See Also
-
Collection<T>
DiscountCollection(ref Product)
Initializes a new instance of the DiscountCollection class.
[Obsolete("Use constructor overload which takes a PriceContext")]
public DiscountCollection(ref Product product)
Parameters
product
Product- The product.
- See Also
-
Collection<T>
Properties
Country
Gets the country.
public Country Country { get; }
Property Value
- See Also
-
Collection<T>
Currency
Gets the currency.
public Currency Currency { get; }
Property Value
- See Also
-
Collection<T>
Difference
Gets the difference.
public double Difference { get; }
Property Value
- double
- The difference.
- See Also
-
Collection<T>
HasDiscounts
Gets a value indicating whether this instance has discounts.
public bool HasDiscounts { get; }
Property Value
- bool
true
if this instance has discounts; otherwise,false
.
- See Also
-
Collection<T>
Price
Returns the price for the product when discounts are subtracted.
public PriceInfo Price { get; }
Property Value
- PriceInfo
- The price.
- See Also
-
Collection<T>
PriceWithDifference
Gets the price with difference.
public double PriceWithDifference { get; }
Property Value
- double
- The price with difference.
- See Also
-
Collection<T>
TotalDiscount
Gets the total discount.
public PriceInfo TotalDiscount { get; }
Property Value
- PriceInfo
- The total discount.
- See Also
-
Collection<T>
Methods
ClearCache()
Clears the cache.
public static void ClearCache()
- See Also
-
Collection<T>
GetTotal(bool, CalculationType, bool)
Returns the total discount in a number of different ways.
public double GetTotal(bool includeVat, CalculationType calculateAs, bool doRounding)
Parameters
includeVat
bool- Should VAT be included in the returned discount
calculateAs
CalculationType- Indicates wheter the result should be returned as an amount or as a percentage of the original product price
doRounding
bool- Should the result be rounded. If the propertys return result is percentage and rounding is in effect, the result will be with two decimals
Returns
- double
- System.Double.
Exceptions
- InvalidOperationException
- Thrown when Unable to parse calculated percent from discount total/product price
- ArgumentException
- Thrown when
calculateAs
is not known as discount calculation type
- See Also
-
Collection<T>
GetTotalDiscount()
Gets the total discount.
public PriceInfo GetTotalDiscount()
Returns
- PriceInfo
- The total discount.
- See Also
-
Collection<T>