Magento 2 remove decimal points from the price

In this post we will show you Magento 2 remove decimal points from the price, hear for remove decimal points from the price in Magento 2 we will give you demo and example for implement.

Magento 2 remove decimal points from the price
Magento 2 remove decimal points from the price

How to remove decimal digits in price of product Magento 2

Price of product is : 116,00 $ => 116 $
Price of product is : 116.00 $ => 116 $
Price of product is : 15,116.00 => 15,116

In order to remove decimal digits in price of product magento, we need to custom some code

we will show you How to remove decimal digits in price of product magento. For Magento 2 remove decimal points from the price you need this code.

METHOD 1 # remove decimal points from the price using script

You need to override vendor/magento/module-catalog/view/base/web/js/price-utils.js and change the value of precision on line 38:

from

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

to

var precision = 0,

METHOD 2 # remove decimal points from the price using code

You can do using price helper class, Go to vendor\magento\framework\Pricing\PriceCurrencyInterface.php and use this code.

$this->helper('Magento\Framework\Pricing\Helper\Data')->currency(number_format(50,2),true,false);

Hope this code and post will helped you for implement Magento 2 remove decimal points from the price. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve onlincode. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs onlincode.org