0

I've set GBP as my default and only enabled currency.

I have an exposed filter on my view so users can enter a maximum price. Say the user enters 300 the filter works and displays only items that go up to £300. The same for it the user entered 300.00 - it works.

However, when the user enters 300,000, i think Drupal is thinking of the comma as a decimal, so it thinks 300,000 and 300,00 means 300 and so my view shows results over 300 and up to 300 thousand.

Can I fix this, if so how? Thanks for reading

1
  • I've just noticed, if the user enters 300,000 - ie they want to show all products up to 300 thousand, they get no results, presumablly Drupal thinks 300,000 is 300 pound ?
    – carlbowles
    Dec 5, 2014 at 10:11

1 Answer 1

1

'300,000' isn't a number, it's a string. If you run

print (int) '300,000';

You'll get "300" as the response. '300.00' is a number, which is why it's treated as one.

So your issue isn't with Drupal Commerce, rather PHP and your users' input.

You'll need to implement some validation to correct your users' input before Commerce uses it. You can either do this by adding an extra validation function to the form using hook_form_alter(), or with some simple Javascript attached to the input box(es).

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.