When using more then 2 digits ex(9.4880 will be displayed as 9.49) for the price the js will override this value and it will format using the round for 2 digits.
Going deeer found the issue in price-utils.js on this line
// replace(/-/, 0) is only for fixing Safari bug which appears
// when Math.abs(0).toFixed() executed on '0' number.
// Result is '0.-0' :(
am = Number(Math.round(Math.abs(amount - i) + 'e+' + precision) + ('e-' + precision));
r = (j ? i.substr(0, j) + groupSymbol : '') +
i.substr(j).replace(re, '$1' + groupSymbol) +
(precision ? decimalSymbol + am.toFixed(2).replace(/-/, 0).slice(2) : '');
am.toFixed(2) <--- is using the hardcoded precision and the price will be overrided with 2 digits value !!!
done a quick check and changing this to
am.toFixed(precision)
seems to do the job.
Thanks,
Calin.
@cdiacon your suggestion looks perfectly valid to me, could you please prepare a pull request?
Generally, when you see something in code you would like to change, it can be proposed directly as pull request, there is no need in reporting issue first.
Thanks @orlangur makes sense
Created a PR here https://github.com/magento/magento2/pull/14350
Hi @cdiacon. Thank you for your report.
The issue has been fixed in magento/magento2#14350 by @cdiacon in 2.2-develop branch
Related commit(s):
The fix will be available with the upcoming 2.2.5 release.
Hi @cdiacon. Thank you for your report.
The issue has been fixed in magento/magento2#14461 by @mastiuhin-olexandr in 2.3-develop branch
Related commit(s):
The fix will be available with the upcoming 2.3.0 release.
Hi @cdiacon. Thank you for your report.
The issue has been fixed in magento/magento2#15926 by @dmytro-ch in 2.1-develop branch
Related commit(s):
The fix will be available with the upcoming 2.1.15 release.