This contribution implements the MS3 tax class for the MS2 codebase.Advantages
- Queries for tax class once and not on EACH price display
- Faster page renders (fewer queries)
Disadvantages
- none
The tax class is initiated in application_top.php and each time a tax rate is queried it checks to see if the class is already set. If the value is set it returns that but if not set will query the database.
For pages with lots of prices (categories, specials, all_products, etc) the savings will be huge. For individual product pages the impact will be minimal.
Click on the links and scroll to the bottom of the page for debug info.
STEP 1 - Upload the file (new so should not overwrite anything)
The only file to be uploaded is *catalog*/includes/classes/tax.phpSTEP 2 - Edit includes/application_top.php
Add this to the bottom of includes/application_top.php just above the "?>" closing tag.// tax class require('includes/classes/tax.php'); $osC_Tax = new osC_Tax;STEP 3 - Edit includes/functions/general.php
REPLACE tep_get_tax_rate() it with this code:function tep_get_tax_rate($class_id, $country_id = -1, $zone_id = -1) { global $customer_zone_id, $customer_country_id, $osC_Tax; return $osC_Tax->getTaxRate($class_id, $country_id, $zone_id); }REPLACE tep_get_tax_description() it with this code:function tep_get_tax_description($class_id, $country_id, $zone_id) { global $osC_Tax; return $osC_Tax->getTaxRateDescription($class_id, $country_id, $zone_id); }
osCommerce is a community driven organization and as such the support base will fall entirely on the forum members. The base class is thoroughly commented and should be easy to follow for any coder. I offer limited support in-between paid projects (feeding my family comes first before volunteer time).
If you use this contribution and find it useful a small donation can be made via PayPal. This will enable me to offer one-on-one support and also fund releasing other contributions. In addition, if you make a donation it'll make you eligible for other performance optimization contributions that are not released!
The tax class is pulled from the MS3 CVS and credit goes entirely to the osC Dev Team. I just ported it for MS2...