Class OrderFormPriceMatrix
Container for all prices that can be associated with the line items in the referenced order form.
Inheritance
Inherited Members
Namespace: EPiServer.Commerce.Marketing
Assembly: EPiServer.Business.Commerce.dll
Version: 13.30.0Syntax
public class OrderFormPriceMatrix
Remarks
Since there might be multiple promotions modifying the same line item, you may have an intermediate state where you have different prices for a subset of the line item quantity.
Use case: You have a line item in your cart with a quantity of three. First a promotion is applied that gives 10% discount to one of those items. After that there is a buy 3 get the cheapest for free promotion applied. Since one of the items in the line item has a reduced price, the correct item that is for free should be that, and the savings should be the price after the first 10% reduction. That case is what this matrix handles. Without it, the 10% reduction would have been spread out on all the items in the line item, making the saving from the second promotion incorrect.
Constructors
OrderFormPriceMatrix(IOrderForm, PromotionEngineContentLoader, ContentReference)
Creates an instance of a OrderFormPriceMatrix.
Declaration
[Obsolete("This constructor is no longer used. Using overload constructor with currency instead. Will remain at least until February 2020.")]
public OrderFormPriceMatrix(IOrderForm orderForm, PromotionEngineContentLoader promotionEngineContentLoader, ContentReference campaignFolderRootLink)
Parameters
Type | Name | Description |
---|---|---|
IOrderForm | orderForm | The order form to operate on. |
PromotionEngineContentLoader | promotionEngineContentLoader | The promotion content loader. |
EPiServer.Core.ContentReference | campaignFolderRootLink | The campaign folder root link. |
OrderFormPriceMatrix(IOrderForm, PromotionEngineContentLoader, ContentReference, Currency)
Creates an instance of a OrderFormPriceMatrix.
Declaration
[Obsolete("This constructor is no longer used. Using overload constructor without PromotionEngineContentLoader instead. Will remain at least until February 2020.")]
public OrderFormPriceMatrix(IOrderForm orderForm, PromotionEngineContentLoader promotionEngineContentLoader, ContentReference campaignFolderRootLink, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IOrderForm | orderForm | The order form to operate on. |
PromotionEngineContentLoader | promotionEngineContentLoader | The promotion content loader. |
EPiServer.Core.ContentReference | campaignFolderRootLink | The campaign folder root link. |
Currency | currency | The currency. |
OrderFormPriceMatrix(IOrderForm, ContentReference, Currency)
Creates an instance of a OrderFormPriceMatrix.
Declaration
public OrderFormPriceMatrix(IOrderForm orderForm, ContentReference campaignFolderRootLink, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IOrderForm | orderForm | The order form to operate on. |
EPiServer.Core.ContentReference | campaignFolderRootLink | The campaign folder root link. |
Currency | currency | The currency. |
Properties
CheapestFirst
Contains sorting action for sorting by price in ascending order - passed as parameter to ExtractPrices.
Declaration
public static Action<List<PriceEntry>> CheapestFirst { get; }
Property Value
Type | Description |
---|---|
System.Action<System.Collections.Generic.List<PriceEntry>> |
MostExpensiveFirst
Contains sorting action for sorting by price in descending order - passed as parameter to ExtractPrices.
Declaration
public static Action<List<PriceEntry>> MostExpensiveFirst { get; }
Property Value
Type | Description |
---|---|
System.Action<System.Collections.Generic.List<PriceEntry>> |
Remarks
This should be the default sorting action - use unless there are very specific requirements.
Prices
Declaration
public List<PriceEntry> Prices { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<PriceEntry> |
Methods
CalculateAndCommit(AffectedEntries, Func<IEnumerable<PriceEntry>, Decimal, Decimal>)
Calculate and commit changes that have been made to a previously extracted set of entries.
Declaration
protected decimal CalculateAndCommit(AffectedEntries item, Func<IEnumerable<PriceEntry>, decimal, decimal> apply)
Parameters
Type | Name | Description |
---|---|---|
AffectedEntries | item | The batch of price changes to commit. |
System.Func<System.Collections.Generic.IEnumerable<PriceEntry>, System.Decimal, System.Decimal> | apply | The calculation method. |
Returns
Type | Description |
---|---|
System.Decimal | The saved amount. |
CommitPrices(AffectedEntries)
Commit changes that has been made to a previously extracted set of entries.
Declaration
public void CommitPrices(AffectedEntries prices)
Parameters
Type | Name | Description |
---|---|---|
AffectedEntries | prices | The batch of price changes to commit. |
ExtractEntries(IEnumerable<String>, Decimal, PromotionData)
Extract a range of entries from the price matrix.
Declaration
public AffectedEntries ExtractEntries(IEnumerable<string> codes, decimal quantity, PromotionData promotionData)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | codes | The product codes to extract prices for. |
System.Decimal | quantity | The total quantity of entries to extract. |
PromotionData | promotionData | The promotion responsible for extracting the current subset of entries. |
Returns
Type | Description |
---|---|
AffectedEntries | An AffectedEntries with information about the extracted data. If less than the requested
|
Remarks
If codes
is null, then all entries on the order form will be part of the selection.
ExtractEntries(IEnumerable<String>, Decimal, Action<List<PriceEntry>>, PromotionData)
Extract a range of entries from the price matrix.
Declaration
public AffectedEntries ExtractEntries(IEnumerable<string> codes, decimal quantity, Action<List<PriceEntry>> sortMethod, PromotionData promotionData)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | codes | The product codes to extract prices for. |
System.Decimal | quantity | The total quantity of entries to extract. |
System.Action<System.Collections.Generic.List<PriceEntry>> | sortMethod | Determines the ordering of entries to extract. |
PromotionData | promotionData | The promotion responsible for extracting the current subset of entries. |
Returns
Type | Description |
---|---|
AffectedEntries | An AffectedEntries with information about the extracted data. If less than the requested
|
Remarks
If codes
is null, then all entries on the order form will be part of the selection.
GetExcludedPriceEntries(PromotionData)
Get PriceEntry attached to applied promotions which exclude promotionData
,
or is excluded by it, or is excluded by a specific promotion setting.
Declaration
public IEnumerable<PriceEntry> GetExcludedPriceEntries(PromotionData promotionData)
Parameters
Type | Name | Description |
---|---|---|
PromotionData | promotionData | The promotion data. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<PriceEntry> | Returns all PriceEntry attached to excluded promotions. |
IsDoubleExclusion(PromotionData)
Determines whether PromotionData is excluding each other with former applied promotions.
Declaration
public bool IsDoubleExclusion(PromotionData promotionData)
Parameters
Type | Name | Description |
---|---|---|
PromotionData | promotionData | The promotion to check with others. |
Returns
Type | Description |
---|---|
System.Boolean |
IsExcluded(PromotionData)
Determines whether the supplied PromotionData has been previously excluded by other committed promotions.
Declaration
public bool IsExcluded(PromotionData promotionData)
Parameters
Type | Name | Description |
---|---|---|
PromotionData | promotionData | The promotion supplied to determine whether it's excluded. |
Returns
Type | Description |
---|---|
System.Boolean | Returns |
RemoveConditionEntries(IEnumerable<String>, Decimal, Action<List<PriceEntry>>)
Remove conditional entries from the price matrix instance.
Declaration
public OrderFormPriceMatrix RemoveConditionEntries(IEnumerable<string> codes, decimal quantity, Action<List<PriceEntry>> sortMethod)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | codes | The product codes to extract prices for. |
System.Decimal | quantity | The total quantity of entries to extract. |
System.Action<System.Collections.Generic.List<PriceEntry>> | sortMethod | Determines the ordering of entries to extract. |
Returns
Type | Description |
---|---|
OrderFormPriceMatrix |
Remarks
If codes
is null, then all entries on the order form will be part of the selection.
RemoveConditionEntries(IEnumerable<String>, Decimal, Action<List<PriceEntry>>, PromotionData)
Remove conditional entries from the price matrix instance.
Declaration
public OrderFormPriceMatrix RemoveConditionEntries(IEnumerable<string> codes, decimal quantity, Action<List<PriceEntry>> sortMethod, PromotionData promotionData)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | codes | The product codes to extract prices for. |
System.Decimal | quantity | The total quantity of entries to extract. |
System.Action<System.Collections.Generic.List<PriceEntry>> | sortMethod | Determines the ordering of entries to extract. |
PromotionData | promotionData | The promotion responsible for removing the conditional entries. |
Returns
Type | Description |
---|---|
OrderFormPriceMatrix |
Remarks
If codes
is null, then all entries on the order form will be part of the selection.
ResetPrices()
Resets prices that has been extracted but not committed.
Declaration
protected void ResetPrices()
Remarks
This method can be called to ensure that no price data gets lost. If a set of extracted prices has not been committed by calling CommitPrices(AffectedEntries), then calling this method ensures that the original prices are returned to the price matrix. This method is also called implicitly by UpdateDiscount(DiscountUpdater) so in normal circumstances there should not be any reason to call this method.
UpdateDiscount(DiscountUpdater)
Declaration
protected void UpdateDiscount(DiscountUpdater discountUpdater)
Parameters
Type | Name | Description |
---|---|---|
DiscountUpdater | discountUpdater |