2

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

For Example,

$500.00 => $500

$19.99 => $19.99

Any help will be appreciated.

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.

| improve this answer | |
  • 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 github.com/lillik/magento2-price-decimal/issues/41 – Kumar May 29 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

| improve this answer | |
  • Hey, I tried your solution but it'll do rounding of the price. for example, $4.50 => $5... – Abhishek Panchal Mar 9 '17 at 18:36
  • 1
    This solution works for me. – P_U Nov 14 '17 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 – Pramod Kharade Dec 28 '17 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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