Skip to content
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

Open
sandrodunkel opened this issue Dec 16, 2024 · 3 comments
Open

[5.x]: Currency Formatting on …DiscountAsCurrency #3816

sandrodunkel opened this issue Dec 16, 2024 · 3 comments

Comments

@sandrodunkel
Copy link

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 returns CHF-100.00, so currency, NO space, value.

Steps to reproduce

  1. Use Commerce in a headless project (don't know if regular usage also has this problem)
  2. Use a negative pricing value in any …AsCurrency property (e.g. storedTotalDiscountAsCurrency)

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

Copy link

linear bot commented Dec 16, 2024

@nfourtythree
Copy link
Contributor

Hi @sandrodunkel

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 -CHF 123.45, -123,45 CHF and -123.45 CHF.

Thanks!

@sandrodunkel
Copy link
Author

Hey @nfourtythree – I'm using de-CH (German in Switzerland). The correct way here it would be CHF -123.45. This change should affect all in Craft available locales from Switzerland (de-CH, fr-CH, it-CH, en-CH).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants