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

Support money_without_trailing_zeros filter #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Hybrid-Force
Copy link

Previously, price parsing depends on the amount/amount_no_decimals config. It assumes that there will be trailing zeros if the format is amount. It can not handle scenarios where money format is amount while money_without_trailing_zeros filter is used in rendering.

After the patch, parsing has no assumption on the format. It takes care of .s in prices and try to parse them as floats.

The first part (^[^0-9]+) of the regex /^[^0-9]+|[^0-9.]/g handle format prefixes with dots, e.g. Dhs. {{amount}} AED, Rs. {{amount}}. The second part of the regex get the number part of the price.

It can handle formats like $99.90 USD, $99 USD, Dhs. 99.90 AED, Dhs. 99 AED, and three decimal formats 99.900 BHD.

Simplify price parsing and support for `money_without_trailing_zeros` liquid filter.
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