Tax Calculation with the Tax Provider
In this guide, you’ll learn how tax lines are calculated using the tax provider.
Tax Lines Calculation#
Tax lines are calculated and retrieved using the getTaxLines method of the Tax Module’s main service. It accepts an array of line items and shipping methods, and the context of the calculation.
For example:
The context object is used to determine which tax regions and rates to use in the calculation. It includes properties related to the address and customer.
The example above retrieves the tax lines based on the tax region for the United States.
The method returns tax lines for the line item and shipping methods. For example:
Using the Tax Provider in the Calculation#
The tax lines retrieved by the getTaxLines
method are actually retrieved from the tax region’s Tax Module Provider.
A tax module implements the logic to shape tax lines. Each tax region uses a tax provider.
Learn more about tax providers, configuring, and creating them in the Tax Module Provider guide.