WooCommerce: Set Customer Default Tax Location

The WooCommerce settings allow you to define the default customer tax location (“Calculate tax based on” -> “Shop base address“). In this case, when a guest customer enters the checkout, tax will be calculated based on the store address.

The problem is that this option is unusual – businesses require the “Calculate tax based on” -> “Customer billing address” option in most cases.

So, today, we will be setting the default tax location when “Customer billing address” has been chosen AND the customer is either logged out (so, no billing address is set) or logged in but have no saved address (for example, a brand new customer). Enjoy!

It’s unusual to pick the “Shop base address” option for establishing the tax amounts. The snippet below will define a default tax location when “Customer billing address” is chosen instead and the customer has no billing address yet.

PHP Snippet: Set Customer Default Billing Country for Tax Calculations @ WooCommerce Checkout

 * @snippet       Set Customer Default Tax Location
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 8
 * @community     https://businessbloomer.com/club/

add_filter( 'woocommerce_get_tax_location', 'bbloomer_customer_default_tax_location', 9999, 3 );

function bbloomer_customer_default_tax_location( $location, $tax_class, $customer ) {
    if ( $customer && ! $customer->get_billing_country() ) {
        return array( 'US', '', '', '' );
    return $location;

Note: you can even set the default state, postcode and city by using the 3 array values after the country code e.g. ( ‘US’, ‘CA’, ‘90210’, ‘Beverly Hills’ )

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce: Tax Exempt User Based on Checkout Field Value
    There is a nice WooCommerce function you can use to exempt someone from Tax/VAT calculations. You could, for example, enable exemption once they enter a Tax/VAT number, or maybe if they specify a given ZIP code. Such function is called set_is_vat_exempt(), and together with a little trick to “get” a checkout field on the go, […]
  • WooCommerce: Add Column to “Users” Admin Table
    On the admin side, you might need to display WooCommerce information inside the users table (WordPress Dashboard > Users). For example, their billing country. Or their phone number. Or maybe some custom calculation e.g. the number of completed orders. Either way, this is super easy. First, we add a new column – second, we tell […]
  • WooCommerce B2B: How to Set Up a Wholesale Store
    The ecommerce sector is seeing incredible growth, year after year, with no foreseeable end in sight. The same is true for B2B ecommerce, yet there aren’t many good platform choices available for small-to-medium businesses that want to sell wholesale. There are several SaaS solutions on the market, but these are costly, closed-source, and mostly oriented […]
  • WooCommerce: Display Prices Inc + Ex Tax
    The WooCommerce settings allow you to show prices including OR excluding tax. But what if we want to show both at the same time e.g. “$100 inc. tax – $89 ex. tax”? Well, by combining the snippet below with the snippet I already coded for variable products price range, or by installing our Mini/Plugin, you […]
  • Tax display by customer role?
    In a WooCommerce store, I have two roles: Customer and Professional. In the WooCommerce options, I have selected to display prices in the cart and checkout with taxes included. Now, I need for the Professional role to have the opposite setting, that in the cart and checkout the prices are displayed without taxes included. Is there a way to […]

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

Questions? Feedback? Customization? Leave your comment now!

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Your email address will not be published. Required fields are marked *