Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Hi guys,

I am supposed to enable the visitor to add to cart 3.2 meters of a certain product, but when I type 3.2 into the quantity box, it won't allow me to add it to cart and displays an error saying I should either enter 3 or 4.

Then I noticed in /addons/cart/config.php we have this line: $pp['allow_decimal_qty'] = 0;

I've set it to $pp['allow_decimal_qty'] = 1; but there is no effect.

Couldn't find a topic discussing this issue, so if anyone has a suggestion what I can try to make this work, it will be much appreciated.

Thanks!
Hi,

when I type 3.2 into the quantity box, it won't allow me to add it to cart and displays an error saying I should either enter 3 or 4.

As far as Couch is concerned (which is to say, the backend PHP code), if $pp['allow_decimal_qty'] is not set to 1 (which is the default) and one tries to input a decimal as quantity, it will simply ignore the submission and the item will not show up in the cart - it will *not* throw an error of any kind.

So, if you happen to be getting an error, it can only be by the front-end code (i.e. the markup you are using to create the product form). Please study your code and see if there is any frontend validation or any other JS routine that is preventing decimal as input.

One tell-tale sign of the problem being on the frontend would be that your hitting 'Add to cart' will not get the form to submit (i.e. reach Couch at the server).

Hope this helps.
Thanks KK, I have followed your advice and took a closer look into my code.

Posting this here, if someone has this same issue in the future:

Issue was that the input box for the quantity had a step of 1, when I changed it to step="0.1", it allowed for decimal places.

Thanks again!
You are welcome :)
4 posts Page 1 of 1

Who is online

In total there are 15 users online :: 1 registered, 0 hidden and 14 guests
(based on users active over the past 5 minutes)

Users browsing this forum: Google [Bot] and 14 guests