Class DefaultShippingCalculator
The default shipping calculator.
Inheritance
Implements
Inherited Members
Namespace: EPiServer.Commerce.Order.Calculator
Assembly: EPiServer.Business.Commerce.dll
Version: 13.30.0Syntax
public class DefaultShippingCalculator : IShippingCalculator
Constructors
DefaultShippingCalculator(ILineItemCalculator, IReturnLineItemCalculator)
Initialize a new instance of the DefaultShippingCalculator class.
Declaration
[Obsolete("This constructor is no longer used, use constructor with ITaxCalculator instead. Will remain at least until May 2019.")]
public DefaultShippingCalculator(ILineItemCalculator lineItemCalculator, IReturnLineItemCalculator returnLineItemCalculator)
Parameters
Type | Name | Description |
---|---|---|
ILineItemCalculator | lineItemCalculator | The line item calculator. |
IReturnLineItemCalculator | returnLineItemCalculator | The return line item calculator. |
DefaultShippingCalculator(ILineItemCalculator, IReturnLineItemCalculator, ITaxCalculator, ServiceCollectionAccessor<IShippingPlugin>, ServiceCollectionAccessor<IShippingGateway>)
Initialize a new instance of the DefaultShippingCalculator class.
Declaration
public DefaultShippingCalculator(ILineItemCalculator lineItemCalculator, IReturnLineItemCalculator returnLineItemCalculator, ITaxCalculator taxCalculator, ServiceCollectionAccessor<IShippingPlugin> shippingPluginsAccessor, ServiceCollectionAccessor<IShippingGateway> shippingGatewaysAccessor)
Parameters
Type | Name | Description |
---|---|---|
ILineItemCalculator | lineItemCalculator | The line item calculator. |
IReturnLineItemCalculator | returnLineItemCalculator | The return line item calculator. |
ITaxCalculator | taxCalculator | The tax calculator. |
EPiServer.ServiceLocation.ServiceCollectionAccessor<IShippingPlugin> | shippingPluginsAccessor | |
EPiServer.ServiceLocation.ServiceCollectionAccessor<IShippingGateway> | shippingGatewaysAccessor |
Methods
CalculateReturnSalesTax(IShipment, IMarket, Currency)
Calculates the sales tax of all return line items of an IShipment.
Declaration
protected virtual Money CalculateReturnSalesTax(IShipment shipment, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IShipment | shipment | The shipment. |
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 return sales tax. |
CalculateReturnShippingTax(IShipment, IMarket, Currency)
Calculates the shipping tax of all return line items of an IShipment.
Declaration
protected virtual Money CalculateReturnShippingTax(IShipment shipment, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IShipment | shipment | The shipment. |
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 return shipping tax. |
CalculateSalesTax(IShipment, IMarket, Currency)
Calculates the sales tax of an IShipment.
Declaration
protected virtual Money CalculateSalesTax(IShipment shipment, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IShipment | shipment | The shipment. |
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 sales tax. |
CalculateShippingCost(IOrderForm, IMarket, Currency)
Calculates the shipping cost of the orderForm
.
Declaration
[Obsolete("This method is no longer used. Will remain at least until May 2019.")]
protected virtual Money CalculateShippingCost(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 shipping cost of the order form. |
CalculateShippingCost(IOrderGroup, IMarket, Currency)
Gets shipping cost of the orderGroup
.
Declaration
[Obsolete("This method is no longer used. Will remain at least until May 2019.")]
protected virtual Money CalculateShippingCost(IOrderGroup orderGroup, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IOrderGroup | orderGroup | The order group. |
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 shipping cost of the order group. |
CalculateShippingCost(IShipment, IMarket, Currency)
Calculates the shipping cost for the shipment
.
Declaration
protected virtual Money CalculateShippingCost(IShipment shipment, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IShipment | shipment | The shipment. |
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 subtotal of the shipment with full precision. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The currency returned from the shipping provider cannot be converted to the |
System.TypeInitializationException | The shipping method points to an unexisting class name. |
CalculateShippingItemsTotal(IShipment, Currency)
Calculates the subtotal for all line items in an IShipment.
Declaration
protected virtual Money CalculateShippingItemsTotal(IShipment shipment, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IShipment | shipment | The shipment. |
Currency | currency | The currency to be used in the calculation. |
Returns
Type | Description |
---|---|
Money | The subtotal of the shipment. |
CalculateShippingReturnItemsTotal(IShipment, Currency)
Calculates the total of prices for all return line items in an IShipment.
Declaration
protected virtual Money CalculateShippingReturnItemsTotal(IShipment shipment, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IShipment | shipment | The shipment. |
Currency | currency | The currency to be used in the calculation. |
Returns
Type | Description |
---|---|
Money | The return subtotal of the shipment. |
CalculateShippingTax(IShipment, IMarket, Currency)
Calculates the shipping tax of an IShipment.
Declaration
protected virtual Money CalculateShippingTax(IShipment shipment, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IShipment | shipment | The shipment. |
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 shipping tax with full precision. |
CanBeConverted(Money, Currency)
Determines whether the result can be converted to a specific currency.
Declaration
protected virtual bool CanBeConverted(Money moneyFrom, Currency currencyTo)
Parameters
Type | Name | Description |
---|---|---|
Money | moneyFrom | The money from. |
Currency | currencyTo | The currency to. |
Returns
Type | Description |
---|---|
System.Boolean |
|
GetDiscountedShippingAmount(IShipment, IMarket, Currency)
Gets the shipping cost with all shipping discounts applied of an IShipment.
Declaration
public Money GetDiscountedShippingAmount(IShipment shipment, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IShipment | shipment | The shipment. |
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 discounted subtotal of the shipment. |
Examples
public void GetDiscountedShippingAmount(IShipment shipment, IMarket market, Currency currency, IShippingCalculator shippingCalculator)
{
var shippingDiscountedAmount = shippingCalculator.GetDiscountedShippingAmount(shipment, market, currency);
Debug.WriteLine("Shipping discounted amount for shipment '{0}': {1}", shipment.ShipmentId, shippingDiscountedAmount);
}
Exceptions
Type | Condition |
---|---|
System.ComponentModel.DataAnnotations.ValidationException | If validation fails. |
GetReturnSalesTax(IShipment, IMarket, Currency)
Gets the sales tax for an IShipment that contains IReturnLineItem. The shipment must belong to an IReturnOrderForm.
Declaration
public Money GetReturnSalesTax(IShipment shipment, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IShipment | shipment | The return shipment. |
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 sales tax of the return shipment. |
Examples
public void GetReturnSalesTax(IShipment shipment, IMarket market, Currency currency, IShippingCalculator shippingCalculator)
{
var returnSalesTax = shippingCalculator.GetReturnSalesTax(shipment, market, currency);
Debug.WriteLine("Sales tax for return shipment '{0}': {1}", shipment.ShipmentId, returnSalesTax);
}
GetReturnShippingTax(IShipment, IMarket, Currency)
Gets the shipping tax for an IShipment that contains IReturnLineItem. The shipment must belong to an IReturnOrderForm.
Declaration
public Money GetReturnShippingTax(IShipment shipment, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IShipment | shipment | The return shipment. |
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 shipping tax of the return shipment. |
Examples
public void GetReturnShippingTax(IShipment shipment, IMarket market, Currency currency, IShippingCalculator shippingCalculator)
{
var returnShippingTax = shippingCalculator.GetReturnShippingTax(shipment, market, currency);
Debug.WriteLine("Shipping tax for return shipment '{0}': {1}", shipment.ShipmentId, returnShippingTax);
}
GetReturnShippingTotals(IShipment, Currency)
Gets the shipping totals of a return IShipment.
Declaration
public ShippingTotals GetReturnShippingTotals(IShipment shipment, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IShipment | shipment | The shipment. |
Currency | currency | The currency to be used in the calculation. |
Returns
Type | Description |
---|---|
ShippingTotals | A shipping totals of a return IShipment that excludes value of shipping cost and shipping tax. |
Examples
public void GetReturnShippingTotals(IShipment shipment, Currency currency, IShippingCalculator shippingCalculator)
{
var shippingTotals = shippingCalculator.GetReturnShippingTotals(shipment, currency);
Debug.WriteLine("Subtotal for shipment '{0}': {1}", shipment.ShipmentId, shippingTotals.ItemsTotal);
}
GetSalesTax(IShipment, IMarket, Currency)
Gets the sales tax of an IShipment.
Declaration
public Money GetSalesTax(IShipment shipment, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IShipment | shipment | The shipment. |
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 sales tax of the shipment. |
Examples
public void GetSalesTax(IShipment shipment, IMarket market, Currency currency, IShippingCalculator shippingCalculator)
{
var salesTax = shippingCalculator.GetSalesTax(shipment, market, currency);
Debug.WriteLine("Sales tax for shipment '{0}': {1}", shipment.ShipmentId, salesTax);
}
GetShipmentDiscountPrice(IShipment, Currency)
Gets the shipment discount.
Declaration
[Obsolete("This method is no longer used, use extension IShipment.GetShipmentDiscountPrice instead. Will remain at least until May 2019.")]
public Money GetShipmentDiscountPrice(IShipment shipment, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IShipment | shipment | The shipment. |
Currency | currency | The currency. |
Returns
Type | Description |
---|---|
Money | The shipment discount. |
GetShippingCost(IOrderForm, IMarket, Currency)
Gets the shipping cost of the orderForm
.
Declaration
[Obsolete("This method is no longer used, use IOrderFormCalculator.GetShippingSubTotal instead. Will remain at least until May 2019.")]
public Money GetShippingCost(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 shipping cost of the order form. |
Exceptions
Type | Condition |
---|---|
System.ComponentModel.DataAnnotations.ValidationException | If validation fails. |
GetShippingCost(IOrderGroup, IMarket, Currency)
Gets the shipping cost of the orderGroup
.
Declaration
[Obsolete("This method is no longer used, use IOrderGroupCalculator.GetShippingSubTotal instead. Will remain at least until May 2019.")]
public Money GetShippingCost(IOrderGroup orderGroup, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IOrderGroup | orderGroup | The order group |
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 shipping cost of the order group. |
Exceptions
Type | Condition |
---|---|
System.ComponentModel.DataAnnotations.ValidationException | If validation fails. |
GetShippingCost(IShipment, IMarket, Currency)
Gets the shipping cost of an IShipment.
Declaration
public Money GetShippingCost(IShipment shipment, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IShipment | shipment | The shipment. |
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 shipping cost of the shipment with full precision. |
Examples
public void GetShippingCost(IShipment shipment, IMarket market, Currency currency, IShippingCalculator shippingCalculator)
{
var shippingCost = shippingCalculator.GetShippingCost(shipment, market, currency);
Debug.WriteLine("Shipping cost for shipment '{0}': {1}", shipment.ShipmentId, shippingCost);
}
Exceptions
Type | Condition |
---|---|
System.ComponentModel.DataAnnotations.ValidationException | If validation fails. |
GetShippingItemsTotal(IShipment, Currency)
Gets the total of prices of all line items in an IShipment.
Declaration
public Money GetShippingItemsTotal(IShipment shipment, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IShipment | shipment | The shipment. |
Currency | currency | The currency to be used in the calculation. |
Returns
Type | Description |
---|---|
Money | The subtotal of the shipment. |
Examples
public void GetShippingItemsTotal(IShipment shipment, Currency currency, IShippingCalculator shippingCalculator)
{
var shipmentSubtotal = shippingCalculator.GetShippingItemsTotal(shipment, currency);
Debug.WriteLine("Subtotal for shipment '{0}': {1}", shipment.ShipmentId, shipmentSubtotal);
}
Exceptions
Type | Condition |
---|---|
System.ComponentModel.DataAnnotations.ValidationException | If validation fails. |
GetShippingMethods()
Gets all the shipping methods in the system.
Declaration
protected virtual ShippingMethodDto GetShippingMethods()
Returns
Type | Description |
---|---|
ShippingMethodDto |
GetShippingReturnItemsTotal(IShipment, Currency)
Gets the total of prices of all return line items in an IShipment. The shipment must belong to an IReturnOrderForm.
Declaration
public Money GetShippingReturnItemsTotal(IShipment shipment, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IShipment | shipment | The shipment. |
Currency | currency | The currency to be used in the calculation. |
Returns
Type | Description |
---|---|
Money | The return subtotal of the shipment. |
Examples
public void GetShippingReturnItemsTotal(IShipment shipment, Currency currency, IShippingCalculator shippingCalculator)
{
var shippingItemTotal = shippingCalculator.GetShippingReturnItemsTotal(shipment, currency);
Debug.WriteLine("Total prices of all return line items for shipment '{0}': {1}", shipment.ShipmentId, shippingItemTotal);
}
GetShippingTax(IShipment, IMarket, Currency)
Gets the shipping tax of an IShipment.
Declaration
public Money GetShippingTax(IShipment shipment, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IShipment | shipment | The shipment. |
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 shipping tax of the shipment with full precision. |
Examples
public void GetShippingTax(IShipment shipment, IMarket market, Currency currency, IShippingCalculator shippingCalculator)
{
var shippingTax = shippingCalculator.GetShippingTax(shipment, market, currency);
Debug.WriteLine("Shipping tax for shipment '{0}': {1}", shipment.ShipmentId, shippingTax);
}
GetShippingTotals(IShipment, IMarket, Currency)
Gets the shipping totals of an IShipment.
Declaration
public ShippingTotals GetShippingTotals(IShipment shipment, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IShipment | shipment | The shipment. |
IMarket | market | The market to be used in the calculation. |
Currency | currency | The currency to be used in the calculation. |
Returns
Type | Description |
---|---|
ShippingTotals | A shipping totals. |
Examples
public void GetShippingTotals(IShipment shipment, IMarket market, Currency currency, IShippingCalculator shippingCalculator)
{
var shippingTotals = shippingCalculator.GetShippingTotals(shipment, market, currency);
Debug.WriteLine("Subtotal for shipment '{0}': {1}", shipment.ShipmentId, shippingTotals.ItemsTotal);
Debug.WriteLine("Shipping cost for shipment '{0}': {1}", shipment.ShipmentId, shippingTotals.ShippingCost);
Debug.WriteLine("Shipping tax for shipment '{0}': {1}", shipment.ShipmentId, shippingTotals.ShippingTax);
}
ValidateSalesTax(Money)
Validates the sales tax.
Declaration
protected virtual void ValidateSalesTax(Money money)
Parameters
Type | Name | Description |
---|---|---|
Money | money | The calculated value. |
Exceptions
Type | Condition |
---|---|
System.ComponentModel.DataAnnotations.ValidationException | If validation fails. |
ValidateShippingCostForOrder(Money)
Validates the shipping cost.
Declaration
[Obsolete("This method is no longer used. Will remain at least until May 2019.")]
protected virtual void ValidateShippingCostForOrder(Money money)
Parameters
Type | Name | Description |
---|---|---|
Money | money | The calculated value. |
Exceptions
Type | Condition |
---|---|
System.ComponentModel.DataAnnotations.ValidationException | If validation fails. |
ValidateShippingCostForOrderForm(Money)
Validates the shipping cost.
Declaration
[Obsolete("This method is no longer used. Will remain at least until May 2019.")]
protected virtual void ValidateShippingCostForOrderForm(Money money)
Parameters
Type | Name | Description |
---|---|---|
Money | money | The calculated value. |
Exceptions
Type | Condition |
---|---|
System.ComponentModel.DataAnnotations.ValidationException | If validation fails. |
ValidateShippingCostForShipment(Money)
Validates the shipping cost.
Declaration
protected virtual void ValidateShippingCostForShipment(Money money)
Parameters
Type | Name | Description |
---|---|---|
Money | money | The calculated value. |
Exceptions
Type | Condition |
---|---|
System.ComponentModel.DataAnnotations.ValidationException | If validation fails. |
ValidateShippingItemTotal(Money)
Validates the shipping item total.
Declaration
protected virtual void ValidateShippingItemTotal(Money money)
Parameters
Type | Name | Description |
---|---|---|
Money | money | The calculated value. |
Exceptions
Type | Condition |
---|---|
System.ComponentModel.DataAnnotations.ValidationException | If validation fails. |
ValidateShippingTax(Money)
Validates the shipping tax.
Declaration
protected virtual void ValidateShippingTax(Money money)
Parameters
Type | Name | Description |
---|---|---|
Money | money | The calculated value. |
Exceptions
Type | Condition |
---|---|
System.ComponentModel.DataAnnotations.ValidationException | If validation fails. |