---
title: Tax calculator
slug: commerce-connect-15/docs/tax-calculator
docTags: 
createdAt: 2026-07-30T20:34:42.000Z
---

## Sales tax

- **For a single line item** – Calculates sales tax based on the market, the shipping address, and the base price.

```csharp
public Money CalculateSalesTax(ILineItem lineItem, IMarket market, IOrderAddress shippingAddress, Money basePrice, ITaxCalculator taxCalculator) {
  return taxCalculator.GetSalesTax(lineItem, market, shippingAddress, basePrice);
}
```

- **For a collection of line items** - Calculates sales tax based on the market, the shipping address, and the currency.

```csharp
public Money CalculateSalesTax(IEnumerable<ILineItem> lineItems, IMarket market, IOrderAddress shippingAddress, Currency currency, ITaxCalculator taxCalculator) {
  return taxCalculator.GetSalesTax(lineItems, market, shippingAddress, currency);
}
```

## Change the default calculation

Inherit from `DefaultTaxCalculator`, the default implementation of `ITaxCalculator`, and override one or more of its methods to change the calculation behavior. For example, override `GetTaxValues` to change how tax values are looked up, or `GetTaxCategoryNameById` to change how a tax category name is resolved from its ID.

```csharp
public class TaxCalculatorOverridingDefault: DefaultTaxCalculator {
  public TaxCalculatorOverridingDefault(IContentRepository contentRepository, ReferenceConverter referenceConverter): base(contentRepository, referenceConverter) {}
  protected override string GetTaxCategoryNameById(int taxCategoryId) {
    return string.Empty;
  }
  protected override IEnumerable<ITaxValue> GetTaxValues(string taxCategory, string languageCode, IOrderAddress orderAddress) {
    return new List<ITaxValue>() {
      new TaxValue(10, "SalesTax", "clothing", TaxType.SalesTax)
    };
  }
}
```
