I think I may have the solution to this bug. It requires two minor changes to the following files:
admin/includes/functions/general.php
admin/includes/classes/currencies.php
In admin/includes/functions/general.php we have the 'zen_add_tax' function at around line 1671. This looks like this:
Code:
/* function zen_add_tax($price, $tax) {
global $currencies;
if (DISPLAY_PRICE_WITH_TAX_ADMIN == 'true') {
return zen_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']) + zen_calculate_tax($price, $tax);
} else {
return zen_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
}
}
This returns the price with or without tax added dependent on the value of DISPLAY_PRICE_WITH_TAX_ADMIN which is set in Configuration>>My Store>>Display Prices with Tax in Admin.
By definition a function named 'zen_add-tax' when called should add the tax regardless so my solution is to change this function to the following:
Code:
function zen_add_tax($price, $tax) {
global $currencies;
return zen_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']) + zen_calculate_tax($price, $tax);
}
This change alone results in the tax inclusive price being displayed correctly in admin in orders and invoices, however it also results in the product prices in Catalog>>Categories/Products displaying as the tax inclusive price regardless of the value of DISPLAY_PRICE_WITH_TAX_ADMIN. This is not the desired result and requires a change to the 'display_price' function in admin/includes/classes/currencies.php
At around line 65 this looks like
Code:
function display_price($products_price, $products_tax, $quantity = 1) {
return $this->format(zen_add_tax($products_price, $products_tax) * $quantity);
}
This function sets how the price is displayed and therefore it is here that I believe the value of DISPLAY_PRICE_WITH_TAX_ADMIN should effect the return value. My solution is to change this function to the following:
Code:
function display_price($products_price, $products_tax, $quantity = 1) {
if (DISPLAY_PRICE_WITH_TAX_ADMIN == 'true') {
return $this->format(zen_add_tax($products_price, $products_tax) * $quantity);
}
else {
return $this->format($products_price * $quantity);
}
}
I have tested this on a v1.5 site and cannot find any adverse effects of these changes in either Admin or in the Store. Being 'Admin' files I would not expect any issues in the Store as a result of these changes.
If anyone finds any issues associated with these changes perhaps they could post these here.
I hope this helps.
Alan
Bookmarks