Follow bellow steps:
Step : 1 First copy core file from app/code/core/Mage/Tax/Helper/Data.php
to local app/code/local/Mage/Tax/Helper/Data.php
or override helper data
After replace bellow functions
public function getPrice($product, $price, $includingTax = null, $shippingAddress = null, $billingAddress = null,
$ctc = null, $store = null, $priceIncludesTax = null, $roundPrice = true)
{
if (!$price) {
return $price;
}
$store = $this->_app->getStore($store);
if (!$this->needPriceConversion($store)) {
return $store->roundPrice($price);
}
if (is_null($priceIncludesTax)) {
$priceIncludesTax = $this->priceIncludesTax($store);
}
$percent = $product->getTaxPercent();
$includingPercent = null;
$taxClassId = $product->getTaxClassId();
if (is_null($percent)) {
if ($taxClassId) {
$request = Mage::getSingleton('tax/calculation')
->getRateRequest($shippingAddress, $billingAddress, $ctc, $store);
$percent = Mage::getSingleton('tax/calculation')
->getRate($request->setProductClassId($taxClassId));
}
}
if ($taxClassId && $priceIncludesTax) {
if ($this->isCrossBorderTradeEnabled($store)) {
$includingPercent = $percent;
} else {
$request = Mage::getSingleton('tax/calculation')->getRateOriginRequest($store);
$includingPercent = Mage::getSingleton('tax/calculation')
->getRate($request->setProductClassId($taxClassId));
}
}
if ($percent === false || is_null($percent)) {
if ($priceIncludesTax && !$includingPercent) {
return $price;
}
}
$product->setTaxPercent($percent);
if ($product->getAppliedRates() == null) {
$request = Mage::getSingleton('tax/calculation')
->getRateRequest($shippingAddress, $billingAddress, $ctc, $store);
$request->setProductClassId($taxClassId);
$appliedRates = Mage::getSingleton('tax/calculation')->getAppliedRates($request);
$product->setAppliedRates($appliedRates);
}
if (!is_null($includingTax)) {
if ($priceIncludesTax) {
if ($includingTax) {
/**
* Recalculate price include tax in case of different rates. Otherwise price remains the same.
*/
if ($includingPercent != $percent) {
// determine the customer's price that includes tax
$price = $this->_calculatePriceInclTax($price, $includingPercent, $percent, $store, $product);
}
} else {
$price = $this->_calculatePrice($price, $includingPercent, false, false, $product);
}
} else {
if ($includingTax) {
$appliedRates = $product->getAppliedRates();
if (count($appliedRates) > 1) {
$price = $this->_calculatePriceInclTaxWithMultipleRates($price, $appliedRates);
} else {
$price = $this->_calculatePrice($price, $percent, true, false, $product);
}
}
}
} else {
if ($priceIncludesTax) {
switch ($this->getPriceDisplayType($store)) {
case Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX:
case Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH:
if ($includingPercent != $percent) {
// determine the customer's price that includes tax
$taxablePrice = $this->_calculatePriceInclTax($price, $includingPercent, $percent, $store, $product);
// determine the customer's tax amount,
// round tax unless $roundPrice is set explicitly to false
$tax = $this->getCalculator()->calcTaxAmount($taxablePrice, $percent, true, $roundPrice, $product);
// determine the customer's price without taxes
$price = $taxablePrice - $tax;
} else {
//round tax first unless $roundPrice is set to false explicitly
$price = $this->_calculatePrice($price, $includingPercent, false, $roundPrice, $product);
}
break;
case Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX:
$price = $this->_calculatePrice($price, $includingPercent, false, false, $product);
$price = $this->_calculatePrice($price, $percent, true, false, $product);
break;
}
} else {
switch ($this->getPriceDisplayType($store)) {
case Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX:
$appliedRates = $product->getAppliedRates();
if (count($appliedRates) > 1) {
$price = $this->_calculatePriceInclTaxWithMultipleRates($price, $appliedRates);
} else {
$price = $this->_calculatePrice($price, $percent, true, false, product);
}
break;
case Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH:
case Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX:
break;
}
}
}
if ($roundPrice) {
return $store->roundPrice($price);
} else {
return $price;
}
}
''
protected function _calculatePriceInclTax($storePriceInclTax, $storePercent, $customerPercent, $store, $product=false)
{
$priceExclTax = $this->_calculatePrice($storePriceInclTax, $storePercent, false, false);
$customerTax = $this->getCalculator()->calcTaxAmount($priceExclTax, $customerPercent, false, false, $product);
$customerPriceInclTax = $store->roundPrice($priceExclTax + $customerTax);
return $customerPriceInclTax;
}
''
protected function _calculatePrice($price, $percent, $type, $roundTaxFirst = false, $product = false)
{
$calculator = $this->getCalculator();
if ($type) {
$taxAmount = $calculator->calcTaxAmount($price, $percent, false, $roundTaxFirst, $product);
return $price + $taxAmount;
} else {
$taxAmount = $calculator->calcTaxAmount($price, $percent, true, $roundTaxFirst, $product);
return $price - $taxAmount;
}
}
Step : 2 After copy core file from app/code/core/Mage/Tax/Model/Calculation.php
to local app/code/local/Mage/Tax/Model/Calculation.php
or override model file Calculation.php
and replace code from :
public function calcTaxAmount($price, $taxRate, $priceIncludeTax = false, $round = true)
{
$taxRate = $taxRate / 100;
if ($priceIncludeTax) {
$amount = $price * (1 - 1 / (1 + $taxRate));
} else {
$amount = $price * $taxRate;
}
if ($round) {
return $this->round($amount);
}
return $amount;
}
to
public function calcTaxAmount($price, $taxRate, $priceIncludeTax = false, $round = true, $product = false)
{
if($product) {
echo $product->getId();
}
$taxRate = $taxRate / 100;
if ($priceIncludeTax) {
$amount = $price * (1 - 1 / (1 + $taxRate));
} else {
$amount = $price * $taxRate;
}
if ($round) {
return $this->round($amount);
}
return $amount;
}