1

I'm trying to remove the .00 part from product pricing. On Category page it can be done with JS, and same on page load for product pages. But, when a user makes attribute selection on a product, the price goes back to showing the .00 because JS is set to on page load.

Any idea how I could go about simply removing the .00 by formatting the price itself?

Side note: I only want to remove the decimal part if price ends in .00, our other customer groups have catalog price rules that give them discounts, and for that we have to keep the decimal values in place.

1

You need to make some changes in vendor/magento/module-catalog/view/base/web/js/price-utils.js

Just go to 

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

in your script and set 

var precision = 0

Hope this will solve the issue.

|improve this answer|||||
  • I already try this code in price-utils.js but not working i have use in this line add replace.('.00',' ').below define code return pattern.replace('%s', r).replace(/^\s\s*/, '').replace(/\s\s*$/, '').replace('.00',''); but in this code remove after load actual price after remove zeros – Rv Singh Apr 19 '18 at 13:46
  • Please suggest another solution after loading not shown in old price like this $20.00 instead only $20 – Rv Singh Apr 19 '18 at 13: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.