Handling Sales Tax Based on Order Address with Drupal Commerce

If you're doing business in the United States and you have a physical location in a state you need to be collecting sales tax for that state. You can find more information on whether or not you need to be collecting sales tax at the U.S. Small Business Administration site. Different counties have different tax rates. Today we're just covering the taxes statewide.

Out of the box Commerce's Tax module calculates tax no matter where the order is being shipped to. Let's make some quick changes to the tax rules to update this. We need to make sure that if an order is being shipped to a state our business is located in that we're collecting sales tax.

First of all let's create a tax rule for our state. As an example we'll do North Carolina with a 7% tax rate.

Create a new tax rate for your state

Now we'll configure the tax component. We need to add a condition that checks the customer's address to see if it's in a state we collect sales tax for. Let's add a condition:

Condition: Order address component comparison

Data selector: commerce-line-item:order
Address: Billing Information -> Address
Address component: Administrative area (State / Province)
Operator: Equals
Value: NC

The rule condition to charge state tax

With that condition in place sales tax will only be calculated if the billing address of the order is in the state. If you have locations in multiple states you can create multiple tax rates for each state. If you are shipping products use the shipping address instead of the billing address in case customers are shipping to another state.

For information on how to handle products that are tax exempt check out our article Creating Tax Exempt Products with Drupal Commerce.