Table of Contents


Taxes are generally location based. This means that you need to know the customer's location before you can show them tax. That means that until you gather customer information, your cart's taxes will be set at $0 unless you have a default location set. This article shows you how to set up a default for taxes, and then gather user input for more accurate taxing based on the customer's actual location.

Your customer's location will be used to find the relevant tax rate. Customer information is matched to the established rates. Rates are matched by checking the

  1. Zip/Postal Code / Region (region is an arbitrary location that you can define as needed)
  2. State
  3. Country Code

The system will first look for a matching zip or region. Next it will look for a matching State, and last a matching Country Code. If there are no appropriate rates, the customer will not be charged tax, unless you have a GLOBAL rate set (more about that below)

There are 2 requirements for setting up taxes

  1. Setting up the rates.
  2. Setting up templates to capture customer information

Setting a Default Location

If you want to assume that the customer is in your geographic location by default, you should set a default location.

Go to the following settings page: Cartthrob Settings > Global > Default Location (see Figure 1) and set your default location preferences. If you never collect any location information for this customer during the entire checkout process, the system will assume that their address is in the default location. If any tax rates have been set for that default location, they will be used. This is a good method to guarantee that you always have a fallback for shipping and tax calculations when they are based on the customer's location.

Fig 1. Default Location Screen

Default Customer Location Screen

Setting up tax rates.

Go to the following settings page: Cartthrob Settings > Taxes. You will something like the following:

Fig 2. Tax Settings

Tax Settings

This is the default tax settings screen. Begin adding tax rates for one location. Click "Add Another Row" when you're ready for a new line item.

Fig 3. Cascading Settings

Cascading Settings

Rate lines are checked against the customer's location from top to bottom. The first rate that matches the user's location will be used to calculate their taxes. You must set rates from the most specific to least specific from top to bottom. If, for instance, you set the GLOBAL rate above the UK Rate, rates for the UK would never be returned, as the GLOBAL rate would be evaluated first. You can rearrange rates by dragging and dropping them, so its simple to adjust their order.

Setting up templates

During your customer's visit, capture your customer's location. You can use the update_cart_form to gather the customer's location information. Once you've captured the customer's location, the first matching tax rate will be used to calculate your customer's tax.

Note: CartThrob uses 3-character country codes in all of its tags and forms by default.

Capturing Customer Info

This is a very basic implementation of the update cart form. In this example we're capturing the customer's country code. If you have set your tax settings to tax by country code, or you have a global rate set, taxes will be calculated for the customer location

{exp:cartthrob:update_cart_form }
        {exp:cartthrob:country_select name="country_code" selected="{customer_country_code}"}

    <input type="submit" value="submit" />


Relevant tags:

Capturing Customer Information

add_to_cart_form update_cart_form save_customer_info_form

Outputting Tax Information

cart_tax cart_items_info

Cart Items info tag includes some useful tags that can be used to output item prices including the calculated tax for that item.


Also, we're asked from time to time if there's a method to import tax tables. CartThrob has a tax plugin that uses direct database tables for taxes. You can import your data into this table using standard sql commands

Table: exp_cartthrob_taxes Columns:

  • tax_name Descriptive name
  • percent (ex. 10, not 10%)
  • shipping_is_taxable (1 or 0)
  • state 2 Character state name
  • zip
  • country_code (should be 3 character Alpha codes)

Tax Stacking

At this time there is also no method to stack taxes (for instance apply both a state, and a local tax). This feature may be added in the future, please let us know if you need this feature, and we will be more likely to add it.