lillik/magento2-price-decimal

formatPriceLocale in magento 2.4.5

stephen-larkbury opened this issue · 4 comments

I am getting a console error of formatPriceLocale in magento enterprise 2.4.5, this then prevents the swatch product gallery from working on the product page

I can confirm this issue in magento 2.4.5
Uncaught TypeError: utils.formatPriceLocale is not a function

I also confirm this with 2.4.5.

Shipping price estimation is also broken including checkout (one step checkout at least).

Also for me the layered navigation did not filter the results until I have removed it with composer.

MikyW commented

As a hotfix I removed /vendor/lillik/magento2-price-decimal/view directory. Prices are still displayed with correct precision in frontend after this change.
(I assume this issue will be fixed in next module release so I decided not to use custom module to fix the bug.)

I confirm @MikyW 's hotfix works and that it's the way to go.

The content of lillik/magento2-price-decimal/view is:

  • frontend/requirejs-config.js: it makes a rewrite of Magento_Catalog/js/price-utils replacing it with Lillik_PriceDecimal/js/price-utils
  • frontend/web/js/price-utils.js: the rewrite itself

I have compared the Lillik_PriceDecimal/js/price-utils with the original Magento_Catalog/js/price-utils of the old Magento version (pre 2.4.5) and I found out that it doesn't change anything, it's a simple copy of the original file.

In Magento 2.4.5 Magento_Catalog/js/price-utils was changed, adding the formatPriceLocale function. But, since this module rewrites that file, Lillik_PriceDecimal/js/price-utils is being used instead of the original one and, being a copy of the old version, it doesn't include the new formatPriceLocale function. That's why the "Uncaught TypeError: utils.formatPriceLocale is not a function" error is being triggered.

So, since Lillik_PriceDecimal/js/price-utils had no reason to exist, we can easily drop the lillik/magento2-price-decimal/view and let Magento use its original Magento_Catalog/js/price-utils