Automattic / woocommerce-services

WooCommerce Services is a feature plugin that integrates hosted services into WooCommerce (3.0+), and currently includes automated tax rates and the ability to purchase and print USPS shipping labels.
GNU General Public License v2.0
107 stars 20 forks source link

fix: taxes not calculated for IE when zip code is empty #2415

Open frosso opened 3 years ago

frosso commented 3 years ago

Description

We don’t make an API request to TaxJar if the ZIP code at checkout is empty: https://github.com/Automattic/woocommerce-services/blob/develop/classes/class-wc-connect-taxjar-integration.php#L868 (i.e.: we don’t calculate the taxes if the zip code is empty).

But Ireland does not require ZIP codes (Eirecode) for most addresses. The field is even marked as “optional” on the WC checkout.

So I tested this with WCS&T and lo and behold, I see 0 tax amount: https://d.pr/i/ulK9NH But as soon as I enter a value, I see the (correct, I assume) 23% rate: https://d.pr/i/gumkPl

We can't just remove the empty zip code check, because otherwise this would be erroring out for US addresses.

There are other countries where the zip code is optional. Let's use WC core to identify if the ZIP code is optional for the selected country. Skip tax calculation only if the zip code is not optional and is empty.

frosso commented 3 years ago

Marked as low priority because it hasn't been an issue so far. Feel free to change.