Skip to content

Commit ec48987

Browse files
authored
Fix tax calculation for Ohio, Tax rounding and allow calculating VAT without providing ZIP (#2894)
* Allow round tax at subtotal level, instead of rounding per line * Allow calculating taxes for VAT countries without providing ZIP * add OH to nexus_addresses_workaround * Prevent Undefined variable Notice * Add changelog entries
1 parent bb09262 commit ec48987

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
*** WooCommerce Tax Changelog ***
22

33
= 3.2.2 - 2025-xx-xx =
4+
* Add - Allow round tax at subtotal level, instead of rounding per line.
5+
* Add - Allow calculating taxes for VAT countries without providing ZIP.
6+
* Fix - Taxes were incorrectly calculated using the store’s base address for Ohio.
47
* Fix - Display TaxJar error notices only after taxes are calculated.
58
* Tweak - Log detection of potential incorrect California tax nexus in successful TaxJar API and cached responses.
69

classes/class-wc-connect-taxjar-integration.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,15 @@ class WC_Connect_TaxJar_Integration {
2323

2424
private $expected_options = array(
2525
// Users can set either billing or shipping address for tax rates but not shop
26-
'woocommerce_tax_based_on' => 'shipping',
26+
'woocommerce_tax_based_on' => 'shipping',
2727
// Rate calculations assume tax not included
28-
'woocommerce_prices_include_tax' => 'no',
28+
'woocommerce_prices_include_tax' => 'no',
2929
// Use no special handling on shipping taxes, our API handles that
30-
'woocommerce_shipping_tax_class' => '',
31-
// API handles rounding precision
32-
'woocommerce_tax_round_at_subtotal' => 'no',
30+
'woocommerce_shipping_tax_class' => '',
3331
// Rates are calculated in the cart assuming tax not included
34-
'woocommerce_tax_display_shop' => 'excl',
32+
'woocommerce_tax_display_shop' => 'excl',
3533
// TaxJar returns one total amount, not line item amounts
36-
'woocommerce_tax_display_cart' => 'excl',
34+
'woocommerce_tax_display_cart' => 'excl',
3735
);
3836

3937
/**
@@ -1023,6 +1021,12 @@ public function maybe_apply_taxjar_nexus_addresses_workaround( $body ) {
10231021
'from_country' => 'US',
10241022
'from_state' => 'AZ',
10251023
),
1024+
'US-OH' => array(
1025+
'to_country' => 'US',
1026+
'to_state' => 'OH',
1027+
'from_country' => 'US',
1028+
'from_state' => 'OH',
1029+
),
10261030
);
10271031

10281032
foreach ( $cases as $case ) {
@@ -1099,7 +1103,7 @@ public function calculate_tax( $options = array() ) {
10991103
// Strict conditions to be met before API call can be conducted.
11001104
if (
11011105
empty( $to_country ) ||
1102-
empty( $to_zip ) ||
1106+
( empty( $to_zip ) && ! in_array( $to_country, WC()->countries->get_vat_countries() ) ) ||
11031107
( empty( $line_items ) && ( empty( $shipping_amount ) ) ) ||
11041108
WC()->customer->is_vat_exempt()
11051109
) {
@@ -1441,7 +1445,7 @@ public function smartcalcs_cache_request( $json, $from_state ) {
14411445
$zip_state_cache_key = strtolower( 'tj_tax_' . $to_zip . '_' . $to_state );
14421446
$response = get_transient( $zip_state_cache_key );
14431447
}
1444-
$response = $response ? $response : get_transient( $cache_key );
1448+
$response = ! empty( $response ) ? $response : get_transient( $cache_key );
14451449
if ( $response && 'CA' !== $from_state ) {
14461450
// If $from_state is not California, we need to check for incorrect California tax nexus.
14471451
try {

readme.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ This plugin relies on the following external services:
7171
== Changelog ==
7272

7373
= 3.2.2 - 2025-xx-xx =
74+
* Add - Allow round tax at subtotal level, instead of rounding per line.
75+
* Add - Allow calculating taxes for VAT countries without providing ZIP.
76+
* Fix - Taxes were incorrectly calculated using the store’s base address for Ohio.
7477
* Fix - Display TaxJar error notices only after taxes are calculated.
7578
* Tweak - Log detection of potential incorrect California tax nexus in successful TaxJar API and cached responses.
7679

0 commit comments

Comments
 (0)