Tax Class ZIP code

Jerreck McWilliams asked on April 12, 2014 12:46

I need to add ZIP code as a new property by which you can define a tax class in Kentico.

I know that I would need to create two new tables in the database - one to store the zip codes and their ID, and one to store tax rates for ZIP codes with a foreign key to ZIPID and a foreign key to TaxClassID - but I don't know what all objects and controls in the Kentico project are involved with the process of assigning tax classes to products when they are added to the cart.


  1. What objects do I need to extend to assign my new tax rates to a tax class?
  2. What user controls do I need to modify in order calculate the tax price and total price of products when they are added to a user's cart?

Recent Answers

Jerreck McWilliams answered on April 14, 2014 09:35

TL;DR - I just need to figure out how to bind data to my shopping cart controls from a custom table called TaxClassZIP (just like COM_TaxClassCountry and COM_TaxClassState).

Some connections I've made:

The CMSModules_Ecommerce_Controls_ShoppingCart_ShoppingCartContent class inherits from ShoppingCartStep, which has a property called ShoppingCart.  The ShoppingCart property appears to be exposing properties of the ShoppingCartInfo class.  One of these properties is called ContentTable, which is DataTable object that seems to contain the data for the shopping cart.  If this is true, then I believe I need some way to modify this table to include my new tax rates (or do more than that if the data table is including a computed value).
0 votesVote for this answer Mark as a Correct answer

Jerreck McWilliams answered on April 14, 2014 10:00

I think this article may show me how to what I'm talking about above ^^^

0 votesVote for this answer Mark as a Correct answer

Jakub Oravec answered on April 22, 2014 10:58 (last edited on April 22, 2014 11:00)

Hi Jerreck,

There is a special query named selectshoppingcarttaxes responsible for retrieving taxes from DB.

In Kentico 8 it can be easily customized from Admin UI. Just go to Modules application, edit E-commerce module, switch to Classes tab and edit Tax class record. Then go to Queries tab and edit selectshoppingcarttaxes query.

By default it selects records from COM_TaxClassCountry and COM_TaxClassState (preferably). ##WHERE## macro contains where condition restricting selection only to products present in shopping cart - this where condition is generated in API.

You will probably need ZIP code in your part of query. This can be supplied via customization of TaxClassInfoProvider.GetTaxesInternal(ShoppingCartInfo cart) method.

Customization could look like this (null-check missing, just for illustration):

public class CustomTaxClassInfoProvider : TaxClassInfoProvider
    protected override DataSet GetTaxesInternal(ShoppingCartInfo cart)
       QueryDataParameters parameters = new QueryDataParameters();
            parameters.Add("@CountryID", cart.CountryID);
            parameters.Add("@StateID", cart.StateID);

            var address = AddressInfoProvider.GetAddressInfo(cart.ShoppingCartBillingAddressID);
            parameters.Add("@ZIP", address.AddressZip);

            string where = "SKUID IN (";
            where += // ALL SKUIDs FROM SHOPPING CART
            where += ")";

            // Get taxes
            return SqlHelperClass.ExecuteQuery("ecommerce.taxclass.selectshoppingcarttaxes", parameters, where, null);

If you are using Kentico v7, it not possible to edit this query in Site Manager UI. It is possible to change query directly in DB (CMS_Query table), but application of Hotfix or Upgrade may break your customization.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.