0

It seems that if a user enters a comma in the quantity field (as in 2,000) the system ignores the figures after the comma and will add just the amount before the comma (ie '2').

Is there a way to prevent this happening?

(version 2.4.1)

3 Answers 3

0

You should be able to use HTML5 form validators such as

<input type="number" name="item_qty">
0

My friend-o, I would make use of this addon's extension hooks. You would want to create an extension that hooks to one of these:

https://www.exp-resso.com/docs/extension_hooks.html

Like this one:

store_order_item_add_start

And then parse and modify the quantity value of the form_params variable array where the item quantity value most likely lives. Regular Expression out the commas, or even easier, string replace with an empty value!

http://php.net/manual/en/function.str-replace.php

0

Not the best solution by any means, but you can also use JS to prevent anything but numbers and decimal points from being entered. I do this on CC forms.

<script>
$('#fieldID').on('keypress', function(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
return !(charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57));
});
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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