0

I am getting issue with magento format price by JS. This is not rounding correctly.

For example: A product has price $69.95 and catalog rule also applied on this. New special price comes after applied price rule is 54.955.

Now when i format this new special price using optionsPrice.formatPrice(54.555). It returns $54.55 instead $54.56.

When I changed the value 54.556 or 54.5555, It is rounding correctly.

0

I have fixed this issue after 5 hour digging the code. Issue has fixed by override formatCurrency method in file js/varien/js.js. Changes are given below :

File : js/varien/js.js

Add following line :

price = price*100;
price = Math.round(price.toPrecision(10))/100;

Before :

var i = parseInt(price = Math.abs(+price || 0).toFixed(precision)) + "";

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.