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

Normalize prices to standard english notation using Zend_Locale_Math::normalize #71

Open
wants to merge 2 commits into
base: 3.0
Choose a base branch
from

Conversation

gavro
Copy link

@gavro gavro commented Jul 21, 2014

When using non-english locales you can't save any values with decimals. Using a normalized english value whilst saving fixes this.

Front-end still works with as intended.

…:normalize

When using non-english locales you can't save any values with decimals. Using a normalized english value whilst saving fixes this.
Front-end still works with as intended.
@silverstripe-elliot
Copy link

Looks like Zend_Locale_Math::normalize uses PHP's localeconv() function, which also defines the number of digits to the right of the decimal place (int_frac_digits and frac_digits) as 2. Will this override the BaseCurrencyPrecision value if it's set in the ShopConfig?

You might consider moving this logic into the Price class, since it's used in more than two places within the code.

@gavro
Copy link
Author

gavro commented Jul 21, 2014

Hmm, you're right about the localeconv() call. Will look into a different flow for that.

I've tried getting the logic into Price.php, but it seems whatever you set there (e.g. overriding setAmount/setValue), the EditForm logic (from the current controller) is still overriding the locale (and the value) at the last moment: Both Product & Variation have their own Amount() & Price() functions which might prevent any logic @ Price.php to persist ...?

@gavro
Copy link
Author

gavro commented Jul 22, 2014

Alrighty... Setting LC_NUMERIC to 'en_US' seems to do the trick. Setting the locale in PriceField/setValue() is working.

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

Successfully merging this pull request may close these issues.

2 participants