Ok.
I assume this is a bug in v1.5 off zen cart. Anyways i have created a fix for it with explanation in the code, if anyone can verify this then that would be great, if not then no problem:
replace the code in includes/classes/order.php
between the lines 508-546:
Code:
/*********************************************
* Calculate taxes for this product
*********************************************/
$shown_price = zen_round(zen_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) ,$decimals) * $this->products[$index]['qty'];
$shown_price += zen_round(zen_add_tax($this->products[$index]['onetime_charges'], $this->products[$index]['tax']), $decimals);
$this->notify('NOTIFIY_ORDER_CART_SUBTOTAL_CALCULATE', array('shown_price'=>$shown_price));
// find product's tax rate and description
$products_tax = $this->products[$index]['tax'];
$products_tax_description = $this->products[$index]['tax_description'];
$this->info['subtotal'] += $shown_price;
$totalTaxAdd = 0;
foreach ($taxRates as $taxDescription=>$taxRate)
{
$taxAdd = 0;
if ($taxDescription == $products_tax_description)
{
if (DISPLAY_PRICE_WITH_TAX == 'true')
{
$taxAdd = zen_round($shown_price / (100 + $this->products[$index]['tax']) * $this->products[$index]['tax'], $decimals);
} else
{
$taxAdd = zen_calculate_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'];
+ zen_round(zen_calculate_tax($this->products[$index]['onetime_charges'], $this->products[$index]['tax']), $decimals);
}
if (isset($this->info['tax_groups'][$taxDescription]))
{
$this->info['tax_groups'][$taxDescription] += $taxAdd;
} else
{
$this->info['tax_groups'][$taxDescription] = $taxAdd;
}
}
$totalTaxAdd += $taxAdd;
}
$this->info['tax'] += $totalTaxAdd;
/*********************************************
* END: Calculate taxes for this product
*********************************************/
with this code:
Code:
/*********************************************
* Calculate taxes for this product
*********************************************/
$shown_price = zen_round(zen_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) ,$decimals) * $this->products[$index]['qty'];
$shown_price += zen_round(zen_add_tax($this->products[$index]['onetime_charges'], $this->products[$index]['tax']), $decimals);
$this->notify('NOTIFIY_ORDER_CART_SUBTOTAL_CALCULATE', array('shown_price'=>$shown_price));
// find product's tax rate and description
$products_tax = $this->products[$index]['tax'];
//not required
$products_tax_description = $this->products[$index]['tax_description'];
$this->info['subtotal'] += $shown_price;
$totalTaxAdd = 0;
foreach ($taxRates as $taxDescription=>$taxRate)
{
$taxAdd = 0;
if ($taxDescription <> '0') //since $taxRates = zen_get_multiple_tax_rates(..), and the zen_get_multiple_tax_rates function sets
//rate to 0 and description to unknown for no tax.
//therefore we can ignore when $taxRate = 0.
{
if (DISPLAY_PRICE_WITH_TAX == 'true')
{
//Get the original price without the tax then clculate tax rate
$preTax_Price = $shown_price / (($this->products[$index]['tax']/100) + 1);
$taxAdd = zen_calculate_tax($preTax_Price, $taxRate);
} else
{
// replace $this->products[$index]['tax'] with $taxRate since $this->products[$index]['tax'] is the combined tax rate for multi tax (either summed or compounded)
// and $taxRate is the tax rate for each individual tax.
$taxAdd = zen_calculate_tax($this->products[$index]['final_price']+$this->products[$index]['onetime_charges'], $taxRate) * $this->products[$index]['qty'];
}
if (isset($this->info['tax_groups'][$taxDescription]))
{
$this->info['tax_groups'][$taxDescription] += $taxAdd;
} else
{
$this->info['tax_groups'][$taxDescription] = $taxAdd;
}
}
$totalTaxAdd += $taxAdd;
}
//unset($taxRate) so it can not be used in the next round
unset($taxRate);
$this->info['tax'] += $totalTaxAdd;
/*********************************************
* END: Calculate taxes for this product
*********************************************/
Bookmarks