Currently we use this code to display the price of products on our homepage. But this does load the price excluding tax.

How can I edit the code that the price will be including tax?

$first_amount_before_split = substr($_product->getPrice(), 0, -2);
$my_array = explode(".", $first_amount_before_split);
<a href="<?php echo $_product->getProductUrl() ?>">
    <span class="sticker-wrapper top-right home">
        <span class="sticker prijs">
            <span class="main-price"><?php echo $my_array[0]; ?>,</span>
            <span class="sub-price"><?php echo $my_array[1]; ?></span>


The price is displaying including tax with this code. But it skips the last 0's. So $49,90 becomes $49,9 How can I display 2 decimals

<?php $first_amount_before_split = $this->helper('tax')->getPrice($_product, $_product->getFinalPrice()); 
$my_array = explode(".", $first_amount_before_split); ?>


2 Answers 2


Try this in you phtml file.

$_priceIncludingTax = Mage::helper('tax')
                      ->getPrice($_product, $_product->getFinalPrice());
  • Thanks! I edit my new code, do you know the solution to this?
    – JGeer
    Jan 23, 2015 at 10:24
  • echo number_format($product->getFinalPrice(), '2', '.', ',') Jan 23, 2015 at 12:56
  • How does the entire line look like? This? $first_amount_before_split = $this->helper('tax')->getPrice($_product, $_product->getFinalPrice(), '2', '.', ',');
    – JGeer
    Jan 23, 2015 at 12:59
  • $first_amount_before_split = number_format($this->helper('tax')->getPrice($_product, $_product->getFinalPrice()), '2', '.', ',') Jan 23, 2015 at 13:02
  • hope this worked... ? if so upvote comment also for others reference or edit your question with final answer.... Jan 23, 2015 at 13:07

you can do this by tax helper

$_priceInclTax = Mage::helper('tax')->getPrice($_product, $_finalPrice, true,
            null, null, null, null, null, false);

Here $_finalPrice=$_product->getFinalprice()


 public function getPrice($product, $price, $includingTax = null, $shippingAddress = null, $billingAddress = null,
                             $ctc = null, $store = null, $priceIncludesTax = null, $roundPrice = true)

   Mage_Catalog_Model_Product $product
   float $price inputed product price
   bool $includingTax return price include tax flag
   null|Mage_Customer_Model_Address $shippingAddress
   null|Mage_Customer_Model_Address $billingAddress
   null|int $ctc customer tax class
   null|Mage_Core_Model_Store $store
   bool $priceIncludesTax flag what price parameter contain tax
  return  float
  • Thanks! I edit my new code, do you know the solution to this?
    – JGeer
    Jan 23, 2015 at 10:24
  • please change last false to true
    – Amit Bera
    Jan 23, 2015 at 10:28
  • Tried that, with your code. But when set last false to true, the price will be display as $49,9 instead of $49,9012
    – JGeer
    Jan 23, 2015 at 10:37
  • This helped me, I needed to add 'true' as third parameter, otherwise is worked only sometimes :)
    – 00-BBB
    Oct 10, 2018 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.