Previously, the integration calculated tax in the cart by allowing WooCommerce to fully run through it's calculation process, then send an API request to TaxJar to get the correct tax amounts, create a tax rate in the WooCommerce tax table and finally re-trigger the hooks necessary for WooCommerce to completely run through its calculate totals processes this time using our inserted rates.
This approach was previously necessary but often created conflicts with other plugins that required special handling and logic.
This PR introduces a new approach. Now the integration runs on the woocommerce_after_calculate_totals. It performs an API request to TaxJar and then directly applies the tax to the applicable line items, fees, shipping, etc and recalculates the totals that have been altered. This new process no longer causes hooks to run multiple times which was the root cause of many issues.
Previously, the integration calculated tax in the cart by allowing WooCommerce to fully run through it's calculation process, then send an API request to TaxJar to get the correct tax amounts, create a tax rate in the WooCommerce tax table and finally re-trigger the hooks necessary for WooCommerce to completely run through its calculate totals processes this time using our inserted rates.
This approach was previously necessary but often created conflicts with other plugins that required special handling and logic.
This PR introduces a new approach. Now the integration runs on the woocommerce_after_calculate_totals. It performs an API request to TaxJar and then directly applies the tax to the applicable line items, fees, shipping, etc and recalculates the totals that have been altered. This new process no longer causes hooks to run multiple times which was the root cause of many issues.
Steps to Reproduce
Expected Result
After applying the PR, this should happen.
Click-Test Versions
Specs Passing