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.

2

2 Answers 2

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.

3
  • 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. Mar 12, 2018 at 14:08
  • but this answer doesn't meets the qst. This extension hides all decimal. Not only .00. Oct 17, 2018 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 github.com/lillik/magento2-price-decimal/issues/41 May 29, 2020 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

3
  • Hey, I tried your solution but it'll do rounding of the price. for example, $4.50 => $5... Mar 9, 2017 at 18:36
  • 1
    This solution works for me.
    – P_U
    Nov 14, 2017 at 12:47
  • I TRIED but it is not working for me. We can make product grid price and cost price with 2 precision point Dec 28, 2017 at 12:50

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.