INFO: Charging Customers Tax Based on Zip Code within Commerce Server (229780)



The information in this article applies to:

  • Microsoft Site Server 3.0 Commerce Edition

This article was previously published under Q229780

SUMMARY

To charge tax based upon zip code, it is necessary to create a table in the "Commerce" database with a zip code column and a rate column.

For example, create a table called zip_tax with the fields tax_rate and zip and populate the table with the necessary zip codes and corresponding tax rates.

It is then necessary to create a scriptor component in the pipeline editor to replace the existing tax component (probably in \config\plan.pcf) and utilize a script similar to the following:
   Function mscsexecute(config, orderform, context, flags)

    Dim connection, sqlstmt, RS
    Set connection = CreateObject("ADODB.Connection")
    connection.open(context.DefaultConnectionString)
      
    SQLStmt = "select tax_rate from zip_tax where zip = " &       orderform.bill_to_zip
    	Set RS = connection.Execute(sqlstmt)
    orderform.[_tax_total] = rs.fields("tax_rate").value *       orderform.[_oadjust_subtotal] *.01
    orderform.[_tax_included] = 0 
    Connection.close
   Set connection = Nothing
    MSCSExecute = 1
   end function
				
The scriptor takes the orderform.bill_to_zip value that is already instantiated. The scriptor then looks up the corresponding tax rate and multiplies it by the order subtotal "orderform.[_oadjust_subtotal]"

NOTE: The scriptor multiplies the "tax_rate" by .01 because the tax_rate field is an integer value.

Modification Type:MajorLast Reviewed:6/24/2004
Keywords:kbArtTypeINF kbinfo KB229780