Commerce: Promotions field applyAmount number format doesn't take the preferred locale settings into account

Created on 2 Mar 2021  路  4Comments  路  Source: craftcms/commerce

Description
The field applyAmount in promotions (maybe discounts too, haven't tested yet) doesn't take the preferred number format locale settings into account.

To Reproduce

  1. Set the preferred user language to, for example, 'dutch' & formatting locale to 'same as language'
  2. Add a promotion with a decimal number. In dutch you have to use commas for decimal numbers so for example '0,5'
  3. Go back to the promotion and see that the number now shows as english way with a dot for decimal number, so '0.5'
  4. If you now resave the same promotion without changing the applyAmount field (for example you wanted to edit the description), commerce will save the applyAmount as '5'.

Expected behavior
Promotions need to show the number with the preferred formatting locale settings so resaving existing promotions with decimal numbers don't get converted to wrong amounts.

Additional info

  • Craft version: 3.6.5.1
  • Commerce version: 3.2.14.1
  • PHP version: 7.4.10
馃悶 bug 馃摚 promotions

All 4 comments

Currently the applyAmount input field only accept the period decimal format regardless of the user's preferred language.

That's actually not so according to my tests. If I have set my account preferences so that I need to use commas for decimals. I need to input the promotion _with_ a comma. It then transforms it to a period decimal format, yes.

But for example, save a promotion as '0.5' with the preferences set to use commas, it will get saved as '50'.

I have confirmed this is an issue. Working on a fix now. Will update soon.

I was testing the site's primary language that's why I wasn't able to replicate it. I tested this on user's preferred language and able to replicate the bug now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lukeholder picture lukeholder  路  5Comments

codyjames picture codyjames  路  6Comments

alexanderloewe picture alexanderloewe  路  4Comments

Anubarak picture Anubarak  路  3Comments

sjcallender picture sjcallender  路  6Comments