Class PriceEntry
This class is used to hold information about prices in the OrderFormPriceMatrix. PriceEntry objects should never be created, they should always be fetched from the OrderFormPriceMatrix.
Inheritance
Inherited Members
Namespace: EPiServer.Commerce.Marketing
Assembly: EPiServer.Business.Commerce.dll
Version: 10.8.0Syntax
public class PriceEntry
Remarks
This is primarily used for internal calculations. If you need to manipulate these instances directly you're probably doing something that you shouldn't.
Constructors
PriceEntry(ILineItem)
Initializes a new instance of a PriceEntry.
Declaration
public PriceEntry(ILineItem item)
Parameters
Type | Name | Description |
---|---|---|
ILineItem | item | The parent line item where information will be aggregated. |
PriceEntry(Decimal, Decimal)
Initializes a new instance of a PriceEntry.
Declaration
public PriceEntry(decimal price, decimal quantity)
Parameters
Type | Name | Description |
---|---|---|
System.Decimal | price | The price of one quantity. |
System.Decimal | quantity | The number of items. |
Remarks
This version that doesn't take a line item is primarily intended for testing.
PriceEntry(Decimal, Decimal, ILineItem)
Initializes a new instance of a PriceEntry.
Declaration
public PriceEntry(decimal price, decimal quantity, ILineItem item)
Parameters
Type | Name | Description |
---|---|---|
System.Decimal | price | The price of one quantity. |
System.Decimal | quantity | The number of items. |
ILineItem | item | The parent line item where information will be aggregated. |
Properties
ActualTotal
Total price which may contain rounding adjustments.
Declaration
public decimal ActualTotal { get; }
Property Value
Type | Description |
---|---|
System.Decimal |
CalculatedTotal
Calculated total price of this entry based on current price and quantity.
Declaration
public decimal CalculatedTotal { get; }
Property Value
Type | Description |
---|---|
System.Decimal |
OrderDiscount
The order-level discount.
Declaration
public decimal OrderDiscount { get; set; }
Property Value
Type | Description |
---|---|
System.Decimal |
Remarks
The order discount has already been deducted from the value returned by Price, but is also stored in this property to make it easy to distinguish between order discount and line item discount.
OriginalTotal
The calculated price for the initial creation of this entry.
Declaration
public decimal OriginalTotal { get; }
Property Value
Type | Description |
---|---|
System.Decimal |
ParentItem
The parent item to be used for aggregating price entry information.
Declaration
public ILineItem ParentItem { get; }
Property Value
Type | Description |
---|---|
ILineItem |
Price
The price of a single entry.
Declaration
public decimal Price { get; set; }
Property Value
Type | Description |
---|---|
System.Decimal |
Remarks
Note that negative prices are not allowed.
Quantity
The quantity of entries with this price.
Declaration
public decimal Quantity { get; set; }
Property Value
Type | Description |
---|---|
System.Decimal |
Remarks
Quantity must be greater than zero. I e zero is not a legal value.
Methods
AdjustActualTotal(Decimal)
Used to adjust the actual total in case of rounding errors.
Declaration
public void AdjustActualTotal(decimal adjustment)
Parameters
Type | Name | Description |
---|---|---|
System.Decimal | adjustment | The amount to add to the calculated total to correct a rounding error. |
ShallowCopy()
Returns a copy of the current instance.
Declaration
public PriceEntry ShallowCopy()
Returns
Type | Description |
---|---|
PriceEntry | A new PriceEntry. |
Split(Decimal)
Split this PriceEntry into two.
Declaration
public PriceEntry Split(decimal requestedQuantity)
Parameters
Type | Name | Description |
---|---|---|
System.Decimal | requestedQuantity | The quantity to move to the new entry. |
Returns
Type | Description |
---|---|
PriceEntry | A new PriceEntry with Quantity set to |
Remarks
The original entry will have its quantity reduced by the requestedQuantity. If the original entry has rounding error adjustments in ActualTotal, these adjustments will be retained across the two entries.
Note that merging (with TryMerge(PriceEntry) an entry that has been split (no other modifications), will re-create the exact same PriceEntry as before the split.
TryMerge(PriceEntry)
Tries to merge data from entry
into this instance.
Declaration
public bool TryMerge(PriceEntry entry)
Parameters
Type | Name | Description |
---|---|---|
PriceEntry | entry | The PriceEntry to merge from. Should be discarded after a merge. |
Returns
Type | Description |
---|---|
System.Boolean | True if the merge was successful, False otherwise. |
Remarks
In order for the merge to succeed, both entries must share the same ParentItem and have the same price.