Skip to main content

Ⓒ Sales Tax USA.
All Rights Reserved.

Articles > Guides

How to charge tax in only one state (Sales Tax Nexus setup)

Do you have a Sales Tax Nexus in only one state? Written by Sean OBrien (10/01/2024) Reviewed by Adam Lee (10/07/2025)
Photo Shutterstock / Getty Images

Do you have a Sales Tax Nexus in only one state? Are you painstakingly removing all the other 49 states’ rates out of our WooCommerce Sales Tax CSV? It’s quite common for many of our customers, so now we’ve put together a simple method to help you speed up this process and make charging sales tax in only one state a breeze!

The below WooCommerce code snippet, which can be added to your theme (or child theme’s) functions.php file,  will apply sales tax exclusively to customers in the state you specify, and leave all other state’s using the “Zero Rate” tax class. It’s a useful customization for businesses that have tax obligations only in one state. It also simplies the process of using our WooCommerce CSV by ending the need to edit the file to remove states you don’t want to charge tax in.

This snippet will:
Check if the shipping state of the customer is not the specified state. If so, it sets the tax class to ‘Zero Rate’, effectively applying no tax. Otherwise, the default tax class is used, which is set by our CSV.

Example Situation

Your business is in New York and you have a tax nexus in New York (NY). You are not required to charge sales tax for other states, even though you sell to other states. Upload our CSV file as normal with all state’s rates included, then add the snippet below to your functions.php and include “NY” as the state to charge tax in. Customers with NY addresses will be charged sales tax and customers not from NY will be charged 0.000% (zero rate) sales tax.

In the below snippet, change “NY” to whichever state you require to have taxes applied

/**
 * CHARGE TAX ONLY FOR NY CUSTOMERS
 */

// Apply a custom tax class for customers in New York State
add_filter( 'woocommerce_product_tax_class', 'custom_tax_class_for_newyork', 1, 2 );
function custom_tax_class_for_newyork( $tax_class, $product ) {
    if ( WC()->customer->get_shipping_state() != 'NY' ) {
        return 'Zero Rate';
    }
    return $tax_class;
}

// Adjust tax rates based on customer's shipping state
add_filter( 'woocommerce_matched_rates', 'adjust_tax_rates_for_newyork', 10, 2 );
function adjust_tax_rates_for_newyork( $rates, $tax_class ) {
    if ( WC()->customer->get_shipping_state() != 'NY' ) {
        return []; // Return an empty array to indicate no tax for customers outside NY
    }
    return $rates; // Return the default rates for customers in NY
}

Always make sure to make a backup of your functions.php file before making any changes.

Sean OBrien

Sean is the Founder of Sales Tax USA, a former professional athlete and currently a data expert / software developer specializing in U.S. tax systems and compliance tools.

https://salestaxusa.com/guides/how-to-charge-tax-in-only-one-state/
SHARE:

The easy way to manage sales tax in WooCommerce

Get all 50 US state’s sales tax rates in one handy CSV file. Instant download, install in 1-click.
Learn More

Woocommerce Sales Tax 1

Sales Tax Rates by State

Explore detailed sales tax guides for each U.S. state, including current sales tax rates, economic nexus thresholds, product taxability, registration rules, filing frequencies, and local tax agency resources. Stay compliant and avoid costly mistakes by understanding your state-specific obligations.