Try our conversational search powered by Generative AI!

Class OrderFormPriceMatrix

Container for all prices that can be associated with the line items in the referenced order form.

Inheritance
System.Object
OrderFormPriceMatrix
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Commerce.Marketing
Assembly: EPiServer.Business.Commerce.dll
Version: 10.8.0
Syntax
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(ILineItemCalculator, IOrderForm, Currency)

Creates an instance of a OrderFormPriceMatrix.

Declaration
[Obsolete("The calculator and currency are no longer needed. Use constructor that only takes order form. Will remain at least until September 2017.")]
public OrderFormPriceMatrix(ILineItemCalculator calculator, IOrderForm orderForm, Currency currency)
Parameters
Type Name Description
ILineItemCalculator calculator

The line item calculator to use.

IOrderForm orderForm

The order form to operate on.

Currency currency

The currency to use for calculations and rounding.

OrderFormPriceMatrix(IOrderForm)

Creates an instance of a OrderFormPriceMatrix.

Declaration
public OrderFormPriceMatrix(IOrderForm orderForm)
Parameters
Type Name Description
IOrderForm orderForm

The order form to operate on.

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.

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
protected void CommitPrices(AffectedEntries prices)
Parameters
Type Name Description
AffectedEntries prices

The batch of price changes to commit.

ExtractEntries(IEnumerable<String>, Decimal)

Extract a range of entries from the price matrix.

Declaration
public AffectedEntries ExtractEntries(IEnumerable<string> codes, decimal quantity)
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.

Returns
Type Description
AffectedEntries

An AffectedEntries with information about the extracted data. If less than the requested quantity found, then returns null. The entries will be sorted by Price, with the most expensive first.

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>>)

Extract a range of entries from the price matrix.

Declaration
public AffectedEntries ExtractEntries(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
AffectedEntries

An AffectedEntries with information about the extracted data. If less than the requested quantity found, then returns null.

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>>)

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.

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()

Update the discount information on the line items that were use to populate this price matrix.

Declaration
[Obsolete("This method is no longer used. Call overload that takes a DiscountUpdater parameter. Will remain at least until September 2017.")]
protected void UpdateDiscount()

UpdateDiscount(DiscountUpdater)

Declaration
protected void UpdateDiscount(DiscountUpdater discountUpdater)
Parameters
Type Name Description
DiscountUpdater discountUpdater