Ubercart California Sales Tax


uc_tax_ca is a custom module that we have created for calculating Sales Tax of California. It consists a default csv file to calculate the Sales Tax.

1. Drupal Module to calculate California Sales Tax by ZIP code from a CSV file with admin panel control.
2. Admin Panel Feature:
Default tax rate -> Set your default tax rate when the user not for California state.
Wholesale roles, to exclude from tax -> Exclude a particular user type from sales tax.
Taxed product types -> Select Product types to apply California state sales taxes.
Upload CSV -> Upload a CSV file for calculate tax rate from this file. Please follow the format below:
CSV columns: z2t_ID, ZipCode, SalesTaxRate, RateState, ReportingCodeState, RateCounty, ReportingCodeCounty, RateCity, ReportingCodeCity, RateSpecialDistrict, ReportingCodeSpecialDistrict, City, PostOffice, State, County, PrimaryRecord

3. User END:
California Sales Tax are calculated when the user enters pincode in california range and selected State is California.
If user is not from California and no default tax rates are defined, Sales Tax will not added
If default tax rate is defined and User not from California, default Sales Tax will added.
When no ZIP code found in the range of CSV files, default Sales Tax will added.

uc_tax_ca.zip60.33 KB
California sales tax.pngCalifornia sales tax.png30.82 KB
bellagio's picture
Joined: 12/09/2010
Juice: 60
Re: Ubercart California Sales Tax

Thank you for sharing your work.
May I ask how you would update new sales tax rate?
Do you maually edit csv file? Thank you.

Subhojit's picture
Joined: 07/12/2012
Juice: 12
CSV file upload

Hi bellagio, On the admin panel section there is an option to upload CSV file. A default file already provided by the module but you can change the CSV file but maintain the file format. Basically I had a project and client provide me the CSV. I think it would be provided by any government web site of California. Please maintain the column of the CSV file.

Subhojit Mukherjee

bellagio's picture
Joined: 12/09/2010
Juice: 60
Re: Ubercart California Sales Tax

i downloaded from this site for updated sales tax rate.
(at the very bottom)

Data structure is different compared to your cvs file.

I guess your client manually compare and update your cvs file based on the file form Board of Equalization??

if anybody have more efficient way to update tax rate, could you share your knowledge?

Your module helped me a lot. thank you.

lkujala@driftwoodtechnology.com's picture
Joined: 10/16/2012
Juice: 6
minor tweak needed

I have tried the module; much better than any of the alternatives suggested to date.

One problem with the ZIP codes is when a user enters the full 10 char zip code the lookup stops functioning.
eg 90230 works, but 90230-6948 does not.

The fix should be to split the $zip variable on the '-' and only use the first part of the code. I think this is the only code that needs to be changed.

$zip = $order->delivery_postal_code;
if ( !$state)
$state = $order->billing_zone;
$zip = $order->billing_postal_code;

Also: have you checked the updated (Oct 1, 2012) tax rates?

lkujala@driftwoodtechnology.com's picture
Joined: 10/16/2012
Juice: 6
Sales Tax should not be added when State is not California

The current action of applying the default tax rate when the user is not from california is not a good idea. This breaks the tax calculation for any other state. for instance, this adds california sales tax to *every* transaction even though neither the buyer or seller are located in california.

If you require this behaviour (ie you always charge california sales tax) then this should be an option.

The problem with your design is you are using the same value (default tax rate) for two purposes: 1 - default tax rate when lookup fails and 2 - default tax rate for out of state customer.

Not a big deal: just add field so there is a value for each.

adTumbler's picture
Joined: 08/22/2010
Juice: 33
California sales tax


These are excellent solutions to using zip codes for sales tax in California.

But there are two issue here:

a) Most of the district sales taxes do not follow zip codes - they are district boundaries - e.g. - one side of the 101 in San Rafael is in the city - the other is not and is exempt the city district taxes.

See our AvaTax integration to validate this - addresses that fall across the zip codes are in the demo instructions.


b) The boundaries change regularly

c) One is required to report the taxes collected by district - this is an accounting nightmare

For start ups, this module is excellent and will do fine - for larger companies getting this right is most important

civicsolar's picture
Joined: 06/10/2010
Juice: 48
Re: Ubercart California Sales Tax

The current module could/should be adjusted to look up the California city name from the CSV rather than the zip code. This would handle most zipcode related issues related to California taxes.

phelix's picture
Joined: 06/01/2009
Juice: 64
Drupal 7 and Ubercart V3

I have ported this module to work properly with Drupal 7 and Ubercart 3 if anyone is interested let me know.

uberduberdude's picture
Joined: 07/28/2015
Juice: 3
Re: Ubercart California Sales Tax

YES very interested