Class PriceInfoViewModel
- Namespace
- Dynamicweb.Ecommerce.ProductCatalog
- Assembly
- Dynamicweb.Ecommerce.dll
A snapshot of all price tiers for a product in the current pricing context — the raw price, the discount amount, the final price after discount, and an optional informative/RRP price.
public class PriceInfoViewModel
- Inheritance
-
PriceInfoViewModel
- Inherited Members
Remarks
Obtain a PriceInfoViewModel via the extension methods on ProductViewModel:
@{
var priceInfo = Model.GetPrice();
}
@if (priceInfo.Discount?.Price > 0)
{
<s>@priceInfo.PriceBeforeDiscount.PriceFormatted</s>
<span class="sale">@priceInfo.Price.PriceFormatted</span>
}
else
{
<span>@priceInfo.Price.PriceFormatted</span>
}
@if (priceInfo.InformativePrice?.Price > 0)
{
<small>RRP: @priceInfo.InformativePrice.PriceFormatted</small>
}
To get a unit-specific or stock-location-specific price use the overloads GetPrice(ProductViewModel, string) and GetPrice(ProductViewModel, string, long).
Properties
Discount
Gets or sets the total discount amount. The value is the sum of all applicable discounts for the current context. null or zero when no discount is active.
public PriceViewModel Discount { get; set; }
Property Value
InformativePrice
Gets or sets an optional informative price such as an RRP or manufacturer's suggested retail price. This price is informational only and has no effect on what the customer is charged. null when no informative price is configured for the product.
public PriceViewModel InformativePrice { get; set; }
Property Value
Price
Gets or sets the final price the customer pays — PriceBeforeDiscount minus Discount. This is the value to display as the purchase price.
public PriceViewModel Price { get; set; }
Property Value
PriceBeforeDiscount
Gets or sets the unit price of the product before any discounts are applied. Use this together with Discount to show a strike-through "was" price.
public PriceViewModel PriceBeforeDiscount { get; set; }