---
title: Line item calculator
slug: commerce-connect-13/docs/calculating-orders-line-item-calculator
docTags: 
createdAt: 2026-07-23T09:44:49.000Z
---

- **Extended price** – Calculates the price including order-level discount amount (spread over all line items in the shipment) *and* any line item discount amount.

```csharp
public void GetExtendedPrice(ILineItem lineItem, Currency currency, ILineItemCalculator lineItemCalculator)
       {
         var extendedPrice = lineItemCalculator.GetExtendedPrice(lineItem, currency);
         Debug.WriteLine("Extended price for '{0}': {1}", lineItem.Code, extendedPrice);
       }
```

- **Discounted price** – Only calculates the price with the "line item discount amount," that is, the discount for a specific line item.

```csharp
public void GetDiscountedPrice(ILineItem lineItem, Currency currency, ILineItemCalculator lineItemCalculator)
       {
         var discoutedPrice = lineItemCalculator.GetDiscountedPrice(lineItem, currency);
         Debug.WriteLine("Discounted price for '{0}': {1}", lineItem.Code, discountedPrice);
       }
```

- **Line item price** – Calculates the line item price, which includes a line item's extended price and discounted price.

```csharp
public void GetLineItemPrices(ILineItem lineItem, Currency currency, ILineItemCalculator lineItemCalculator)
       {
         var lineItemdPrices = lineItemCalculator.GetLineItemPrices(lineItem, currency);
         Debug.WriteLine("Extended price for '{0}': {1}", lineItem.Code, lineItemdPrices.ExtendedPrice);
         Debug.WriteLine("Discounted price for '{0}': {1}", lineItem.Code, lineItemdPrices.DiscountedPrice);
       }
```

- **Sales tax** – Calculates a line item's sales tax.

```csharp
public void GetSalesTax(ILineItem lineItem, IMarket market, Currency currency, IOrderAddress shippingAddress, ILineItemCalculator lineItemCalculator)
       {
         var salesTax = lineItemCalculator.GetSalesTax(lineItem, market, currency, shippingAddress);
         Debug.WriteLine("Sales tax for '{0}': {1}", lineItem.Code, salesTax);
       }
```

- **Sales tax** – Calculates line items' sales tax.

```csharp
public Money GetSalesTax(IEnumerable<ILineItem> lineitems, IMarket market, Currency currency, IOrderAddress shippingAddress, ILineItemCalculator lineItemCalculator)
       {
         return lineItemCalculator.GetSalesTax(lineitems, market, shippingAddress, currency);
       }
```

## Change the default calculation

By inheriting from the default implementation of the interface, DefaultLineItemCalculator, you can override the extended price and sales tax calculations. To change the calculation of a line item's extended price, override the CalculateExtendedPrice method. To change the calculation of line item's sales tax, override the CalculateSalesTax method.

```csharp
public class LineItemCalculatorSample : DefaultLineItemCalculator
      {
        protected override Money CalculateExtendedPrice(ILineItem lineItem, Currency currency)
          {
            return new Money(0, currency);
          }
    
        protected override Money CalculateSalesTax(ILineItem lineItem, IMarket market, Currency currency, IOrderAddress shippingAddress)
          {
            return new Money(0, currency);
          }
      }
```

## Change the default validation

The default implementation validates that the extended price and sales tax are not negative after the calculation. To change the behavior, override the ValidateExtendedPrice and ValidateSalesTax methods.

```csharp
public class LineItemCalculatorSample : DefaultLineItemCalculator
      {
        protected override void ValidateExtendedPrice(Money money)
          {
            if (money.Amount <= 0)
              {
                throw new ValidationException("Extended price must be greater than 0");
              }
          }
    
        protected override void ValidateSalesTax(Money money)
          {
            if (money.Amount <= 0)
              {
                throw new ValidationException("Sales tax must be greater than 0");
              }
          }
      }
```
