How to remove the price decimal from Front end price display only on the category and product pages ?

  • For the front end price display on the category and product pages? or are you asking about another part of the site?
    – circlesix
    Jun 25 '16 at 18:24

If you turn on the template hints for your site you will see the price is set in this template:


Copy this file into your theme


Take note of the class that this file is defined from


The price itself is coming from this call:

<?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>

If we take a look at the file that this method is created based on the class it's inheriting (/vendor/magento/framework/Pricing/Render/Amount.php) you will see this method:

 * Format price value
 * @param float $amount
 * @param bool $includeContainer
 * @param int $precision
 * @return float
public function formatCurrency(
    $includeContainer = true,
    $precision = PriceCurrencyInterface::DEFAULT_PRECISION
) {
    return $this->priceCurrency->format($amount, $includeContainer, $precision);

Taking note of the perams in the method, we can see from the template that is displaying the price that we have the definition for the $amount and the $includeContainer but not for the last one $precision which defaults to the constant PriceCurrencyInterface::DEFAULT_PRECISION. This constant is defined in the file /vendor/magento/framework/Pricing/PriceCurrencyInterface.php. Looking in this file we see at the top of the file just after the interface is defined const DEFAULT_PRECISION = 2;. So in the templale we just have to redefine this constant and it will change the default precision based on this value. Setting the value to 0 will do the trick for the category page and for the product page.


<?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>


<?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer(), 0) ?>


This works on the site that I tested on, using USDs. Because Magento supports international currencies and different translations, this method might not work exactly as it does for me. But I don't have any international site set up right now, so I'm not able to test.

  • That is perfect working fine wherever there is a price except in product page Jun 26 '16 at 19:50
  • Yeah, i just saw that. The price get reloaded and changed with some JS in this file /vendor/magento/module-catalog/view/base/web/js/price-box.js. I just need to look into how to override this behavior.
    – circlesix
    Jun 26 '16 at 22:42
  • I found this while looking around, it's not an answer to the question, but might get you down the right path. magento.stackexchange.com/questions/112102/…
    – circlesix
    Jun 27 '16 at 0:08
  • I think this in combination with the JS solution is the right answer to the question. PHP handles rendering the prices from the server, whereas JS handles rendering the dynamically written prices (like in the minicart or when switching between options for configurable products). Mar 2 '17 at 8:32
  • 1
    this is awesome answer.. can you tell me how to remove decimal from product details page May 3 '18 at 11:22

To correct the product page you also should modify next javascript:


on line 38 change

var precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision,


var precision = 0,

Hope this help.

I found this in: Magento 2 : How to remove decimal points from the price

  • Don't modify core files, since they will be overwritten when you upgrade or re-install your installation. Rather use an override in your own design like where the article links to suggests. Mar 2 '17 at 8:31
  • Therefore you would have to add a requirejs-config.js file to some module (/app/code/VENDOR/MODULE/view/frontend/requirejs-config.js) with content var config = { map: { '*': { "Magento_Catalog/js/price-utils": "VENDOR_MODULE/js/price-utils" } } }; Then create a file price-utils.js like /app/code/VENDOR/MODULE/view/frontend/web/js/price-utils.js. For German explanation please see here Mar 31 at 9:21

The price-utils.js solution did not work for me.

But this worked in Magento 2.1: Look in /vendor/magento/framework/Pricing/PriceCurrencyInterface.php

Change const DEFAULT_PRECISION = 2;


Then flush cache.

  • Hi, I tried this answer and changed price in frontend only. how to change in backend also ?
    – Jsparo30
    May 1 '17 at 12:41
  • its work for me but edit vendor file not good practices
    – matinict
    Jun 11 '18 at 6:15

You can use this module


if you are using composer, just run

composer require lillik/magento2-price-decimal
  • This module caused several issues for us, product prices was corrupted
    – cjohansson
    Mar 1 '18 at 8:17
  • While you create new product it mess up all product prices, if a product price is 2,500 it will become 2 as it will remove all digits which come after comma (,) in price. May 26 '18 at 17:41
  • Its not working , product price getting corrupted totally.......... Sep 23 '19 at 11:20

Change this in the file price-utils.js


            (precision ? decimalSymbol + am.toFixed(2).replace(/-/, 0).slice(2) : '');


            (precision ? decimalSymbol + am.toFixed(format.requiredPrecision).replace(/-/, 0).slice(2) : '');

It will dynamically load price precision and you don't have to do anything in js file.Just change in php file and will reflect here :)


I fixed method formatPrecision in vendor/magento/module-directory/Model/Currency.php on line ~301 there was code:

if (!isset($options['precision'])) {
    $options['precision'] = $precision;

I fixed so

if (!isset($options['precision'])) {
    $options['precision'] = ( (floatval($price) - intval($price)) != 0 ? $precision : 0);

To get desired result you have to edit this file


at line 38

var precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision,

replace this with

var precision = 0,

This is for magento2.1.3 this will remove decimals from price digits. This solution helped me

  • Realize that static generated files (the files in pub/static) are overwritten every time you run setup:static-content:deploy. So I wouldn't make this modification here, but rather override /vendor/magento/module-catalog/view/base/web/js/price-utils.js, like Diego suggested. Mar 2 '17 at 8:30
  • don't modify pub/static as mentioned by Giel already.
    – dchayka
    Jul 27 '17 at 18:22

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