3

how to remove only ".00" decimal from price in magento2?

For Example,

$500.00 => $500

$19.99 => $19.99

Any help will be appreciated.

Abhishek Panchal
  • 4,948
  • 3
  • 21
  • 38
  • Take a look here, it might help answer or at least clarify what you are looking to do: http://magento.stackexchange.com/questions/122808/magento-2-how-to-remove-price-decimal/122845#122845 – circlesix Mar 13 '17 at 19:44
  • 1
    I have created a simple extension for this, give it a try: https://github.com/adarshkhatri/price-decimal-magento2 – Adarsh Khatri Oct 23 '18 at 04:18

2 Answers2

1

You can find from below github link for price decimal setting in magento 2,

Price Decimal Setting for Magento 2

After installing extension in your site you need to just set configuration from Stores -> Configuration.

Rakesh Jesadiya
  • 42,221
  • 18
  • 132
  • 183
  • I posted this question 1 year ago tho. But still it will help for other developers who are looking for this kind functionality. I am accepting your answer and upvote. Thanks for sharing. – Abhishek Panchal Mar 12 '18 at 14:08
  • but this answer doesn't meets the qst. This extension hides all decimal. Not only .00. – Adarsh Khatri Oct 17 '18 at 22:30
  • for anyone who is going to use this module , this module has issues !! If you are facing issue with product price update from the backend , this could very well be because of this module . The issue that you will face is price 10,000 usd will be changed to 10 usd after saving the product from the backend . you can refer this open issue at https://github.com/lillik/magento2-price-decimal/issues/41 – Ritesh Kumar May 29 '20 at 14:13
0

You need overwrite the method getPriceFormat of the class Format.

<preference for="Magento\Framework\Locale\Format" type="My\MODULE\Model\Format" />

In your class format

 public function getPriceFormat($localeCode = null, $currencyCode = null)
   {
    .
    .
    $result = [
        //TODO: change interface
        'pattern' => $currency->getOutputFormat(),
        'precision' => 0,
        'requiredPrecision' => 0,
        'decimalSymbol' => $decimalSymbol,
        'groupSymbol' => $groupSymbol,
        'groupLength' => $group,
        'integerRequired' => $integerRequired,
    ];
   }

result 3,858 before 3,858.00