-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.x]: Currency Formatting on …DiscountAsCurrency #3816
Comments
Thank you for your message. Just looking into this, what formatting locale is running when you are seeing this issue? I tried a few different ones and the results I saw were Thanks! |
Hey @nfourtythree – I'm using de-CH (German in Switzerland). The correct way here it would be |
I have been digging into this and I think it is comes down to PHP's Intl extension. But would like to get some further data to confirm. Are you able to run the following CLI command and let me know the output. craft exec/exec "echo \craft\commerce\helpers\Currency::formatAsCurrency(-123.45, 'CHF');" Maybe try this in your local development environment as well as production/staging. Thanks! |
We are going to close this issue for now as it has gone a little stale. In terms of how the code works the formatting of the output is, at the base level, handled by PHP's Intl extension. So it would seem like maybe a version issue with that. Let me know when you have had a chance to run the command mentioned in the previous comment and we can potentially reopen the issue and investigate further. Thanks! |
What happened?
Description
I am using Craft/Craft Commerce headless. All Commerce pricing values that feature the currency format the currency and value the same. e.g.
storedTotalPriceAsCurrency
returns"CHF 100.00"
– so currency, space, value. An issue arises with negative values, probably most commonly used in the discount values, e.g.storedTotalDiscountAsCurrency
, which returnsCHF-100.00
, so currency, NO space, value.Steps to reproduce
Expected behavior
Negative values are returned the same as positive values, meaning currency – space – value.
Example positive value: CHF 100.00
Example negative value: CHF -100.00
Actual behavior
Negative values are formatted differently than positive values.
Example positive value: CHF 100.00 (with space, correct way)
Example negative value: CHF-100.00 (no space, wrong way)
Craft CMS version
Craft Pro 5.5.0
Craft Commerce version
5.2.6
PHP version
8.2.20
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
The text was updated successfully, but these errors were encountered: