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

Ability to customise currency symbols #850

Merged
merged 1 commit into from Mar 6, 2023

Conversation

duncanmcclean
Copy link
Owner

This pull request makes it possible to customise the currency formatting symbols.

Under the hood, Simple Commerce uses PHP's built-in NumberFormatter to take numbers and format them. However, there are some cases where the formatted output it produces isn't correct for some currencies.

This PR adds two config options allowing you to customise two of the currency formatting separators.

It's worth noting that this PR won't change the currency format used in the Money fieldtype in the Control Panel - I don't have time to implement that right now. However, I would accept a pull request if someone needs it.

Example

Normally: £1,234.56

// config/simple-commerce.php

'sites' => [
    'default' => [
        'currency' => 'GBP',

        'currency_formatting' => [
            'thousand_separator' => '.',
            'decimal_separator' => ',',
        ],
    ],
],

With the above config settings, that number turns into £1.234,56.

@duncanmcclean duncanmcclean merged commit d15dc13 into main Mar 6, 2023
@duncanmcclean duncanmcclean deleted the feature/customise-currency-formatting branch March 6, 2023 18:07
@github-actions
Copy link

github-actions bot commented Mar 6, 2023

Released as part of v4.5.7.

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.

None yet

1 participant