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.