London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Class DefaultOrderFormCalculator

The default order form calculator.

Inheritance
System.Object
DefaultOrderFormCalculator
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.Order.Calculator
Assembly: EPiServer.Business.Commerce.dll
Version: 13.30.0
Syntax
public class DefaultOrderFormCalculator : IOrderFormCalculator

Constructors

DefaultOrderFormCalculator(IShippingCalculator)

Initializes a new instance of the DefaultOrderFormCalculator class.

Declaration
public DefaultOrderFormCalculator(IShippingCalculator shippingCalculator)
Parameters
Type Name Description
IShippingCalculator shippingCalculator

The shipping calculator.

DefaultOrderFormCalculator(IShippingCalculator, ILineItemCalculator, ITaxCalculator)

Declaration
[Obsolete("This constructor is no longer used, use constructor without ILineItemCalculator instead. Will remain at least until July 2018.")]
public DefaultOrderFormCalculator(IShippingCalculator shippingCalculator, ILineItemCalculator lineItemCalculator, ITaxCalculator taxCalculator)
Parameters
Type Name Description
IShippingCalculator shippingCalculator
ILineItemCalculator lineItemCalculator
ITaxCalculator taxCalculator

DefaultOrderFormCalculator(IShippingCalculator, ITaxCalculator)

Initializes a new instance of the DefaultOrderFormCalculator class.

Declaration
[Obsolete("This constructor is no longer used, use constructor without ILineItemCalculator and ITaxCalculator instead. Will remain at least until May 2019.")]
public DefaultOrderFormCalculator(IShippingCalculator shippingCalculator, ITaxCalculator taxCalculator)
Parameters
Type Name Description
IShippingCalculator shippingCalculator

The shipping calculator.

ITaxCalculator taxCalculator

The tax calculator.

Methods

CalculateHandlingTotal(IOrderForm, Currency)

Calculates the handling total for the order form. It's intended be overridden.

Declaration
protected virtual Money CalculateHandlingTotal(IOrderForm orderForm, Currency currency)
Parameters
Type Name Description
IOrderForm orderForm

The order form.

Currency currency

The currency to be used in the calculations.

Returns
Type Description
Money

returns 0

CalculateShippingSubTotal(IOrderForm, IMarket, Currency)

Calculates the shipping subtotal of the orderForm.

Declaration
protected virtual Money CalculateShippingSubTotal(IOrderForm orderForm, IMarket market, Currency currency)
Parameters
Type Name Description
IOrderForm orderForm

The order form.

IMarket market

The market to be used in the calculation.

Currency currency

The currency to be used in the calculations.

Returns
Type Description
Money

The shipping subtotal of the order form with full precision.

CalculateSubtotal(IOrderForm, Currency)

Calculates the total of all shipments in the order form.

Declaration
protected virtual Money CalculateSubtotal(IOrderForm orderForm, Currency currency)
Parameters
Type Name Description
IOrderForm orderForm

The order form.

Currency currency

The currency to be used in the calculation

Returns
Type Description
Money

The subtotal for the order form.

CalculateTaxTotal(IOrderForm, IMarket, Currency)

Calculates tax total of the orderForm.

Declaration
protected virtual Money CalculateTaxTotal(IOrderForm orderForm, IMarket market, Currency currency)
Parameters
Type Name Description
IOrderForm orderForm

The order form.

IMarket market

The market to be used in the calculation.

Currency currency

The currency to be used in the calculations.

Returns
Type Description
Money

The tax total of the order form with full precision.

CalculateTotal(IOrderForm, IMarket, Currency)

Calculates the total for the order form.

Declaration
protected virtual Money CalculateTotal(IOrderForm orderForm, IMarket market, Currency currency)
Parameters
Type Name Description
IOrderForm orderForm

The order form.

IMarket market

The market to be used in the calculation.

Currency currency

The currency to be used in the calculation.

Returns
Type Description
Money

The total for the order form.

GetDiscountTotal(IOrderForm, Currency)

Gets the order form discount total.

Declaration
public Money GetDiscountTotal(IOrderForm orderForm, Currency currency)
Parameters
Type Name Description
IOrderForm orderForm

The order form.

Currency currency

The currency.

Returns
Type Description
Money

The order form discount total.

Examples
        public void GetDiscountTotal(IOrderForm orderForm, Currency currency, IOrderFormCalculator orderFormCalculator)
{
var discountTotal = orderFormCalculator.GetDiscountTotal(orderForm, currency);
Debug.WriteLine("Discount total for order form '{0}': {1}", orderForm.OrderFormId, discountTotal);
}

GetHandlingTotal(IOrderForm, Currency)

Gets the handling total for the order form.

Declaration
public Money GetHandlingTotal(IOrderForm orderForm, Currency currency)
Parameters
Type Name Description
IOrderForm orderForm

The order form.

Currency currency

The currency to be used in the calculations

Returns
Type Description
Money

returns 0

Examples
        public void GetHandlingTotal(IOrderForm orderForm, Currency currency, IOrderFormCalculator orderFormCalculator)
{
var handlingTotal = orderFormCalculator.GetHandlingTotal(orderForm, currency);
Debug.WriteLine("Handling total for order form '{0}': {1}", orderForm.OrderFormId, handlingTotal);
}
Exceptions
Type Condition
System.ComponentModel.DataAnnotations.ValidationException

If validation fails.

GetOrderDiscountTotal(IOrderForm, Currency)

Gets the order form discount price.

Declaration
[Obsolete("This method is no longer used. Will remain at least until May 2019.")]
public Money GetOrderDiscountTotal(IOrderForm orderForm, Currency currency)
Parameters
Type Name Description
IOrderForm orderForm

The order form.

Currency currency

The currency.

Returns
Type Description
Money

The order form discount price.

Examples
        public void GetOrderDiscountTotal(IOrderForm orderForm, Currency currency, IOrderFormCalculator orderFormCalculator)
{
var orderDiscountTotal = orderFormCalculator.GetOrderDiscountTotal(orderForm, currency);
Debug.WriteLine("Order discount total for order form '{0}': {1}", orderForm.OrderFormId, orderDiscountTotal);
}

GetOrderFormTotals(IOrderForm, IMarket, Currency)

Gets the order form totals.

Declaration
public OrderFormTotals GetOrderFormTotals(IOrderForm orderForm, IMarket market, Currency currency)
Parameters
Type Name Description
IOrderForm orderForm

The order form.

IMarket market

The market to be used in the calculation.

Currency currency

The currency.

Returns
Type Description
OrderFormTotals

An order form totals.

Examples
        public void GetOrderFormTotals(IOrderForm orderForm, IMarket market, Currency currency, IOrderFormCalculator orderFormCalculator)
{
var orderFormTotals = orderFormCalculator.GetOrderFormTotals(orderForm, market, currency);

Debug.WriteLine("Handling total for order form '{0}': {1}", orderForm.OrderFormId, orderFormTotals.HandlingTotal);
Debug.WriteLine("Shipping subtotal for order form '{0}': {1}", orderForm.OrderFormId, orderFormTotals.ShippingTotal);
Debug.WriteLine("Tax total for order form '{0}': {1}", orderForm.OrderFormId, orderFormTotals.TaxTotal);
Debug.WriteLine("Subtotal for order form '{0}': {1}", orderForm.OrderFormId, orderFormTotals.SubTotal);
Debug.WriteLine("Discount total for order form '{0}': {1}", orderForm.OrderFormId, orderFormTotals.DiscountTotal);
Debug.WriteLine("Total for order form '{0}': {1}", orderForm.OrderFormId, orderFormTotals.Total);
}

GetShippingSubTotal(IOrderForm, IMarket, Currency)

Gets the shipping subtotal of the orderForm.

Declaration
public Money GetShippingSubTotal(IOrderForm orderForm, IMarket market, Currency currency)
Parameters
Type Name Description
IOrderForm orderForm

The order form.

IMarket market

The market to be used in the calculation.

Currency currency

The currency to be used in the calculations.

Returns
Type Description
Money

The shipping subtotal of the order form with full precision.

Examples
        public void GetShippingSubTotal(IOrderForm orderForm, IMarket market, Currency currency, IOrderFormCalculator orderFormCalculator)
{
var shippingSubTotal = orderFormCalculator.GetShippingSubTotal(orderForm, market, currency);
Debug.WriteLine("Shipping subtotal for order form '{0}': {1}", orderForm.OrderFormId, shippingSubTotal);
}
Exceptions
Type Condition
System.ComponentModel.DataAnnotations.ValidationException

If validation fails.

GetSubTotal(IOrderForm, Currency)

Gets the total of all shipments in the order form.

Declaration
public Money GetSubTotal(IOrderForm orderForm, Currency currency)
Parameters
Type Name Description
IOrderForm orderForm

The order form.

Currency currency

The currency to be used in the calculation

Returns
Type Description
Money

The subtotal for the order form.

Examples
        public void GetSubTotal(IOrderForm orderForm, Currency currency, IOrderFormCalculator orderFormCalculator)
{
var subTotal = orderFormCalculator.GetSubTotal(orderForm, currency);
Debug.WriteLine("Subtotal for order form '{0}': {1}", orderForm.OrderFormId, subTotal);
}
Exceptions
Type Condition
System.ComponentModel.DataAnnotations.ValidationException

If validation fails.

GetTaxTotal(IOrderForm, IMarket, Currency)

Gets the tax total of the orderForm.

Declaration
public Money GetTaxTotal(IOrderForm orderForm, IMarket market, Currency currency)
Parameters
Type Name Description
IOrderForm orderForm

The order form.

IMarket market

The market to be used in the calculation.

Currency currency

The currency to be used in the calculation.

Returns
Type Description
Money

The total tax of the order form with full precision.

Examples
        public void GetTaxTotal(IOrderForm orderForm, IMarket market, Currency currency, IOrderFormCalculator orderFormCalculator)
{
var taxTotal = orderFormCalculator.GetTaxTotal(orderForm, market, currency);
Debug.WriteLine("Tax total for order form '{0}': {1}", orderForm.OrderFormId, taxTotal);
}

GetTotal(IOrderForm, IMarket, Currency)

Gets the total for the order form.

Declaration
public Money GetTotal(IOrderForm orderForm, IMarket market, Currency currency)
Parameters
Type Name Description
IOrderForm orderForm

The order form.

IMarket market

The market to be used in the calculation.

Currency currency

The currency to be used in the calculation

Returns
Type Description
Money

The total for the order form.

Examples
        public void GetTotal(IOrderForm orderForm, IMarket market, Currency currency, IOrderFormCalculator orderFormCalculator)
{
var total = orderFormCalculator.GetTotal(orderForm, market, currency);
Debug.WriteLine("Total for order form '{0}': {1}", orderForm.OrderFormId, total);
}
Exceptions
Type Condition
System.ComponentModel.DataAnnotations.ValidationException

If validation fails.

ValidateHandlingTotal(Money)

Validates the handling total.

Declaration
protected virtual void ValidateHandlingTotal(Money money)
Parameters
Type Name Description
Money money

The calculated value.

Exceptions
Type Condition
System.ComponentModel.DataAnnotations.ValidationException

If validation fails.

ValidateShippingSubTotal(Money)

Validates the shipping subtotal.

Declaration
protected virtual void ValidateShippingSubTotal(Money money)
Parameters
Type Name Description
Money money

The calculated value.

Exceptions
Type Condition
System.ComponentModel.DataAnnotations.ValidationException

If validation fails.

ValidateSubtotal(Money)

Validates the subtotal.

Declaration
protected virtual void ValidateSubtotal(Money money)
Parameters
Type Name Description
Money money

The calculated value.

Exceptions
Type Condition
System.ComponentModel.DataAnnotations.ValidationException

If validation fails.

ValidateTaxTotal(Money)

Validates the tax total.

Declaration
protected virtual void ValidateTaxTotal(Money money)
Parameters
Type Name Description
Money money

The calculated value.

Exceptions
Type Condition
System.ComponentModel.DataAnnotations.ValidationException

If validation fails.

ValidateTotal(Money)

Validates the total.

Declaration
protected virtual void ValidateTotal(Money money)
Parameters
Type Name Description
Money money

The calculated value.

Exceptions
Type Condition
System.ComponentModel.DataAnnotations.ValidationException

If validation fails.

Implements