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

Fraction digits - unable to change #1027

Closed
HakimFractal opened this issue May 15, 2019 · 2 comments · Fixed by #1487
Closed

Fraction digits - unable to change #1027

HakimFractal opened this issue May 15, 2019 · 2 comments · Fixed by #1487
Labels
DX & Refactoring Requests for DX improvements and refactorings

Comments

@HakimFractal
Copy link
Contributor

HakimFractal commented May 15, 2019

Fraction digits - hardcoded to 2 in Shopsys\FrameworkBundle\Twig\PriceExtension

What is happening

My post from slack:
Hi. I'm trying to remove "fraction" digits from frontend, so only 123Kc will be showed instead of 123.00Kc. And it is almost impossible (there is no GOOD way to do it).
I thought that you are using CommerceGuys\Intl\Currency\CurrencyRepository, so I copied their JSON configs, set fraction_number to zero, change $definitionPath in constructor and NOTHING. Because you are using your own IntlCurrencyRepository, but you have not override CommerceGuys\Intl\Currency\CurrencyRepository constructor. So I tried to skip your IntlCurrencyRepository and use CommerceGuys directly. NOTHING. Because of Shopsys\FrameworkBundle\Twig\PriceExtension where you have "hardcoded" $numberFormatter->setMinimumFractionDigits(self::MINIMUM_FRACTION_DIGITS);. And this class uses so many private properties and functions, so only way I found is to extend whole PriceExtension.

I've got a response that the latest version uses static::MINIMUM_FRACTION_DIGITS, so it could be overridden. But this does not solve an issue when I want to have different fraction digits count for different domain/language/currency/...

Expected result

You are using CommerceGuys\Intl\Currency\CurrencyRepository, so there should be way to use their configs to set fraction digits and they should override MINIMUM_FRACTION_DIGITS (and maximum too)

@vitek-rostislav
Copy link
Contributor

vitek-rostislav commented Jul 11, 2019

Hi, it should be easier to override the constants in PriceExtension now (they are now protected - #1114)

@vitek-rostislav vitek-rostislav added the DX & Refactoring Requests for DX improvements and refactorings label Aug 12, 2019
@vitek-rostislav
Copy link
Contributor

Hi, as the solution might not be simple, I have created a user story for that, so now, it needs to be evaluated and planned to a sprint. I will let you know once there is any progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX & Refactoring Requests for DX improvements and refactorings
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants