Wrong currency language applied when basket updates from JS
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Wrong currency language applied when basket updates from JS
Laravel framework version: 9.38.0
Aimeos Laravel version: * 2022.07.2
PHP Version: 8.1.12
Environment: Linux
The currency language is correct when the page is refreshed.
The currency language is wrong if a new product is added and the basket updates.
Example:
10.00 лв becomes BGN 10.00
So the problem is not only the currency language, but it seems that the string is not formatted through the translations.
Aimeos Laravel version: * 2022.07.2
PHP Version: 8.1.12
Environment: Linux
The currency language is correct when the page is refreshed.
The currency language is wrong if a new product is added and the basket updates.
Example:
10.00 лв becomes BGN 10.00
So the problem is not only the currency language, but it seems that the string is not formatted through the translations.
Re: Wrong currency language applied when basket updates from JS
The behavior occurs if the basket content is migrated from one locale to another. Make sure, your catalog list/detail and basket URLs all contain the same language/currency (or none).
Also check if you have the appropriate locales in the Locale > Locale panel in the admin backend and that your products all have texts and prices in that language resp. currency.
Also check if you have the appropriate locales in the Locale > Locale panel in the admin backend and that your products all have texts and prices in that language resp. currency.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Wrong currency language applied when basket updates from JS
I have installed a clean Aimeos to test this.
What I've done is include the bg locale with BGN currency in the Locales from this admin page:
/admin/default/jqadm/search/locale
I have turned on Bulgarian in the Languages from this admin page:
/admin/default/jqadm/search/locale/language
I have turned on Bulgarian Lev in the Currencies from this page:
/admin/default/jqadm/search/locale/currency
I have added both the Bulgarian currency and texts for the product that I'm adding to the cart.
The product currency is still not translated properly when added from the cart.
It normally appears as 00.00 лв, but when updated from the updateBasket() in basket-mini.js, it changes to BGN 00.00.
I am looking at this code inside basket-mini.js, is the currency supposed to be translated and formatted here?
What I've done is include the bg locale with BGN currency in the Locales from this admin page:
/admin/default/jqadm/search/locale
I have turned on Bulgarian in the Languages from this admin page:
/admin/default/jqadm/search/locale/language
I have turned on Bulgarian Lev in the Currencies from this page:
/admin/default/jqadm/search/locale/currency
I have added both the Bulgarian currency and texts for the product that I'm adding to the cart.
The product currency is still not translated properly when added from the cart.
It normally appears as 00.00 лв, but when updated from the updateBasket() in basket-mini.js, it changes to BGN 00.00.
I am looking at this code inside basket-mini.js, is the currency supposed to be translated and formatted here?
Code: Select all
const formatter = new Intl.NumberFormat([], {
currency: attr['order.base.currencyid'],
style: "currency"
});
Re: Wrong currency language applied when basket updates from JS
Yes, it's done by the browser in that case which is slightly different from the backend using the PHP Intl extension.kdim95 wrote: ↑16 Nov 2022, 10:00 I am looking at this code inside basket-mini.js, is the currency supposed to be translated and formatted here?Code: Select all
const formatter = new Intl.NumberFormat([], { currency: attr['order.base.currencyid'], style: "currency" });
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Wrong currency language applied when basket updates from JS
In that case if the site is in one language and I have a different browser language, there will be a mismatch in the languages.
I'm looking into Intl, it looks like it accepts a language parameter, which I've set to languageid.
This doesn't seem ideal because there is a slight formatting mismatch with the one in Intl and the one in Aimeos.
The Intl format has an included dot (.) and the price looks like "00.00 лв." instead of "00.00 лв", but I've corrected it with .replace('.', '') , I think it would be best if the formatted price was included in the json response.
I'm looking into Intl, it looks like it accepts a language parameter, which I've set to languageid.
Code: Select all
const languageid = attr['order.base.languageid'];
const formatter = new Intl.NumberFormat(languageid, {
currency: attr['order.base.currencyid'],
style: "currency"
});
The Intl format has an included dot (.) and the price looks like "00.00 лв." instead of "00.00 лв", but I've corrected it with .replace('.', '') , I think it would be best if the formatted price was included in the json response.
Re: Wrong currency language applied when basket updates from JS
Can you create a PR so the improvement also gets into the Aimeos core?
The price can't be returned already formatted by the JSON API because it has to return a standard float value so the API consumer can use it for calculation for example.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star