-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Labels
Fixed in 2.1.xThe issue has been fixed in 2.1 release lineThe issue has been fixed in 2.1 release lineFixed in 2.2.xThe issue has been fixed in 2.2 release lineThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineThe issue has been fixed in 2.3 release lineIssue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passed
Description
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.
Preconditions
- magento 2.2.0
- php 7.0
- mysql 5.7.21
Steps to reproduce
- Create a plugin to use more then 2 digits for the price
- The price should be saved in database as 9.4880
- category page will display the price based on database value, but when accessing the prodcut page the price will be overrided with value 9.49
Expected result
- Price = 9.488
Actual result
- Price = 9.49
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.
Metadata
Metadata
Assignees
Labels
Fixed in 2.1.xThe issue has been fixed in 2.1 release lineThe issue has been fixed in 2.1 release lineFixed in 2.2.xThe issue has been fixed in 2.2 release lineThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineThe issue has been fixed in 2.3 release lineIssue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passed