dotted i

  • Increase font size
  • Default font size
  • Decrease font size
Home

How to configure Virtuemart tax functions to work with U.S. states and zip codes

Virtuemart, v1.1.3, the eCommerce solution which can be bundled with Joomla does not include a native tax code module which works with U.S. states which have any kind of complex regional or district sales tax structure. Off the shelf, the best you can get is a single tax rate for an entire state. The fix which I developed is a more simplified, yet versatile, version of the original fix that was created for Virtuemart 1.0.x. Besides the zip code and custom tax rate need I am also including some loose documentation on how to change some display preferences so that for U.S. customers taxes do not get confusingly added to product prices.  Note that the .zip file has been updated for Virtuemart 1.4 and also includes the relevant ps_checkout.
To download a zip file of procedures and customized files to replace those in the shopping car visit and download:

www.dottedi.biz/tools/virtuemart/checkout.zip (configured for Colorado)

www.dottedi.biz/tools/virtuemart/checkout/custom_zip_codes_CA.tar (California specific zip code list – thanks to Stephen Walsh)

www.dottedi.biz/tools/virtuemart/checkout/IL_WI_ZipCodes.rar (for Illinois and Wisconsin – thanks to Christopher Brimmer)

Probably the most annoying problem with Virtuemart is that it was not designed to accomodate U.S. states with special regional or district tax rates.  In Colorado there are 3 major tax rates depending on your zip code, 2.9%, 4.1%, and 8.2%.

2.9% – This rate we define in the Virtuemart administration screen.

Components --> Virtuemart --> Tax --> List Tax Rates --> USA --> Colorado --> entered as .029

4.1% & 8.2% – For these we set up arrays in custom_tax_tables.php.  Open the file and follow the format or set up the array however it works for you.  If your state has more variations you can add additional arrays.

Save it then open up the custom ps_checkout.php included in the tar file.  Follow down to where I have made notes referencing the include file, custom_zip_codes.php, and update the path as necessary.  There will be comments along the way to help out.  Page further down to where you find the if statements referencing Colorado (CO); update to your state and update the floatval to the correct amount for your zip code array.   Do the same for the second and subsequent arrays which work for your state.  Save and test.  If you want to test on this website locate the Virtuemart demo under the Tools/Apps menu button.

Problem 2: Customers who are logged into their account will be confused and may ask why do the prices appear slightly higher than before signing in?

The other major problem I ran into with Virtuemart is that it is configured by default to have prices include tax if you are logged into your eCommerce account.  Although after you go through the shopping cart and the totals are done correctly there the fact that product price amounts is artificially inflated by the tax will be horribly confusing to a shopper.  What I did was to identify several files where the display is controlled and make very simple modifications to the files to eliminate the confusion.

To fix this problem:

In folder: ~/www/administrator/components/com_virtuemart/html

Replace the following 2 files with the custom ones:

basket.php --> Impacts display on the "Shipping Address, Ship Methods and Payment Method" page
shop.basket_short.php --> This impacts the cart that usually display in the column module

Or change
$product_price = $price["product_price"] * ($my_taxrate+1);
to:
$product_price = $price["product_price"]

If you notice any other weird problems you may need to check out these files as well:

product.product_price_form.php (not sure of any negative effect)
savedbasket.php
tax.tax_form.php
ro_basket.php


Problem: Need to prevent including state tax from displaying by default when buyer is logged in (thus confusing the price)

folder: ~/www/administrator/components/com_virtuemart/classes
file: ps_product.php

Replace with the custom file or change in the file (around line 1420):
if ($auth["show_price_including_tax"] == 1) {
with:
if ($auth["show_price_including_tax"] == 9000000) {

New Info: Per Jeremy the above hacks may not be necessary.  “Simply go into SHOPPERS->LIST SHOPPER GROUPS. Uncheck Show Prices including tax?.”  Here is the relevant screen:

Show Prices Including Tax

Show Prices Including Tax

Tags: , , ,

25 Responses to “How to configure Virtuemart tax functions to work with U.S. states and zip codes”

  1. Steve Says:

    I’m so thankful for this mod. It’s working great! Would you like a copy of the 3878 CA zip codes correctly formatted as ‘zipss1′ in the custom_zip_codes.php file? It took me a long time to format after nabbing the ZIPs off a website! I had to create a ‘zips2′ series for my jurisdiction. Someone could easily reformat it for their jurisdiction. I would send you the general list just with everything formatted as ‘zips1′.

  2. Chetan Says:

    This solutions Seems to be working for Steve… but not for me…

    the files given are with different names then the files given in folder.

  3. bobmeetin Says:

    Chetan, I would need more information than you have given to understand what is going on. First thing to note is that I applied the fix to a site running Joomla 1.5.10 and Virtuemart 1.1.3. If you are looking at an older version of Joomla, 1.0.x then this fix will not work, but there is another workaround. Please note the folder and a couple of the files in the folder and we can compare notes. -Bob

  4. Tristan Waddington Says:

    Thank you so much for this patch! I needed to do some tweaking to make it perfectly, but you saved me hours of work (and my client lots of money). It was exactly what I needed.

    You might consider using the following code in ps_checkout.php to allow administrators to change the state tax rate later on:

    $order_tax = $order_taxable * ($db->f(’tax_rate’) + floatval($denverCustomTaxRate));

    That’s the “state tax rate * custom city rate.”

    …instead of hard coding the rate in like so…

    $order_tax = $order_taxable * floatval( ‘.0772′);

    Again, thank you very much for the patch!

  5. bruce Says:

    This mod works great! One question:

    When checking out, my tax totals look like this:

    Tax Total: $0.28
    Tax Total contains:
    $0.00000 (0% Tax)
    $0.18000 (6% Tax)

    The 6% rate should be 9.25%. Any idea how to fix this?

    Thanks for the great mod. Keep up the good work!

  6. Kenny Says:

    Hi, I’m in NY and there’s no tax on the sale of apparel under $100. We sell various items besides apparel. Does your mod allow us to charge sales tax for a particular category above a particular dollar amount?

  7. bobmeetin Says:

    No, I cannot help with that. This mod which is a rewrite of a mod someone else created for Joomla 1.x is specifically tailored to accomodate district/regional/special tax zones. If you come up with a solution that addresses a particular category or scenario such as no tax if under $100 please post a note here and I’ll add it as a resource.

  8. Mister P Says:

    This looks like exactly the fix I am looking for, *but* I am running VirtueMart 1.0.15 and Joomla 1.0.15. I haven’t worked on trying to incorporate these mods to a 1.0 installation, but if anyone have some hints let me know. I can’t update the site as the client does not have the cashflow to update at this time but really needs to tax fix. Thanks for any tips!

  9. lauren Says:

    Hi,
    I am hoping someone is still here to help me! I have downloaded the files for the Colorado Tax issue and this is wonderful help however I am stuck and need some more direction.

    I have customized the arrays in the zip code file you provided – I live in Arapahoe county so my taxes are a little different than what you stated as The State said I need to collect what I have “in common” with the other cities/counties so some areas will have Arapahoe county taxes in addition to the state and Special Improvement Districts, etc. etc. so I went thru and figured all that out (took hours!!) but it’s done and I added a 3rd array for my needs.

    Anyway, where I am stuck is in the custom ps_checkout.php file. I found the location of the file referenced, custom_zip_codes.php as you mention above but not sure what to do with the path in front of it or what path I am to change and how? Can you be specific (ie exactly what I need to change) and also do I upload the custom_zip_codes file into my file manager and if so, what folder (again please be specific with the exact path)? in the same area as the checkout.php file? This is where I am a bit lost. I don’t know coding or PHP files-I do understanding editing and some HTML and I’ve come this far so would like to get this zip code/tax thing complete so I can have my site go live.

    Thank you so much and your info has been very very helpful!
    Lauren

  10. bobmeetin Says:

    This is not a simple, quick fix. I had some notes at one point on 1.0.x version of Virtuemart which I used when I still had an 1.0.x install which I will see if I can dig up. The problem at this point is that not only is v1.3 out but also 1.4. I just upgraded a site I am building to 1.4 and have the changes in hand to make that work. I will get them posted. To go backwards is going to entail building a simple 1.0.x site, both Joomla and Virtuemart, then testing.

  11. bobmeetin Says:

    My apologies for not responding sooner, but the email notifications for my blog are not working as it should and it’s too easy to forget to check the blog for comments.

    Some history here – I built a site 2+ years ago with Joomla/Virtuemart, don’t remember the versions, but older Joomla and Virtuemart 1.0.something. When I ran into the problem I googled and found a loosely documented application, might have been the Virtuemart forum, I don’t know. It took many communications (about 2 months worth) with the guy who wrote it up, but I did get it working. I am not sure if I still have the notes. With Joomla 1.5.x out for a while and Virtuemart 1.3 I really didn’t think it would be necessary to maintain the info for older versions.

    What you are looking at now are notes I made up for use with Virtuemart 1.3. About a week ago I upgraded a new site to VM 1.4 and took new notes which I plan to publish, but I first need to proof them. It looks like I could have made a few things clearer as well. Give me a couple days and I’ll get back to this and update you.

  12. bobmeetin Says:

    I updated the file list to include the fix relevant to virtuemart 1.4, also updated the README file. You can put the custom_zip_codes file in the same folder as ps_checkout.php. Just make sure that the path is correct so that ps_checkout.php sees it. I don’t work on Windows servers so really can’t advise you here.

    Get the updates at: http://www.dottedi.biz/tools/virtuemart/checkout.zip

  13. bobmeetin Says:

    I looked back through my old notes and found a copy of the ps_checkout.php which ‘may’ work with your version. One of the changes I made between 1.0.x and 1.5 was using an include file, custom_zip_codes file, rather than including the zip code list in ps_checkout.php.

    Get the updates at: http://www.dottedi.biz/tools/virtuemart/checkout.zip which will include the older ps_checkout.php.

  14. Derrick Says:

    Hey I have a quick question, is there anyway you can provide me with a link to the Custom Zips for CA, the link above doesn’t seem to work

  15. bobmeetin Says:

    The ca should have been UPPER CASE. I just switched both the text and link to match the filename. Try:
    http://www.dottedi.biz/tools/virtuemart/checkout/custom_zip_codes_CA.tar

  16. Derrick Says:

    Thanks a lot this is helpful :)

  17. mkemichael Says:

    I have the custom_zip_codes.php for Wisconsin completed if you would like to add it here. Email me and I will send you the file.

    Thanks for sharing your work.

  18. Christopher Says:

    I am glad this was around because it helped me modify it to charge taxes in IL and WI (The two states we have a presence in). If you like, I can send it to you bobmeetin. It works so far in VM 1.1.4

    (bob this is the one with the correct e-mail address in the reply field)

  19. bobmeetin Says:

    Christopher, Thanks for trying it out. If you want to send 2 separate zip files to me I will post them for you with a hearty thanks. Email to bobm@dottedi.biz. -Bob

  20. Jeremy Says:

    “Although after you go through the shopping cart and the totals are done correctly there the fact that product price amounts is artificially inflated by the tax will be horribly confusing to a shopper.”

    Your hacks are not needed for this. Simply go into SHOPPERS->LIST SHOPPER GROUPS. Uncheck Show Prices including tax?.

  21. Ike Says:

    Chris-

    I have an issue as well with tax rate not showing at all. my environment is joomla 1.5 with VM 1.14. I set up Tax rate for NY as 0.0837 and in Configuration set mode “Based on shipping address” Is there any other configuration I am missing? Thank you for any ideas

  22. bobmeetin Says:

    The tax rate should show up after you opt to checkout and you get your billing address input and saved. You also need to make sure you have the function enabled that enables the states dropdown menu.

  23. bobmeetin Says:

    I will double-check. The hack was originally inherited in spirit from VM 1.0 where I could not figure out how to make this work.

  24. Christopher Says:

    Ike,

    I didn’t make any zip code entries within VM itself outside of the based on shipping address. I didn’t add a state tax setting within VM either. All of it was handled within the files listed above.

  25. mike Says:

    Can you please tell me how you can set up 0% tax for wholesale customers (because they do not need to pay tax)?

Leave a Reply