Post by akanov » Fri Feb 01, 2008 10:46 am

I have a problem, while i am trying to input for the quantity in the cart. I can enter value 0.5, 1.2, 2.7, which is not the exact number. How to avoid this?

Newbie

Posts

Joined
Fri Feb 01, 2008 10:06 am

Post by bruce » Sat Feb 02, 2008 4:26 pm

There is no built in user input validation for that. You will have to build it into your copy of opencart.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by marvin » Thu Apr 03, 2008 7:02 pm

Hope this will be fixed on the core code of Opencart. I noticed most of the carts powered by Opencart out there they didn't have validation for quantity, and may cause a serious problem for some if they overlooked it.


I made a  workaround for this. This logic will always round up the quantity if it is in fractions. Let me know if there are problems after applying the fix or if there are other instances i need to apply this logic.  Well this workaround will only apply to cart that sells units that are non-fractions.  Thanks Bruce.

open

yourstore/library/cart.php

on ~line26:
find this:

Code: Select all

$quantity   = $value;
replace with:

Code: Select all

$quantity   = abs(ceil($value));

thanks
Last edited by marvin on Fri Apr 04, 2008 9:23 am, edited 1 time in total.

Newbie

Posts

Joined
Tue Mar 25, 2008 10:35 am

Post by bruce » Thu Apr 03, 2008 7:39 pm

It's not really a bug.

Imagine for a moment, the situation where the item the shop owner is selling has a unit of sale such as weight. These quantites may not be whole units. Food products are an obvious example of this.

Even so, it might be nice to be able to specify some simple product quantity validation for each product using the product administration pages.

eg:
  • a minimum order quantity (to avoid zero and negatives)
  • whole or fractional numbers

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by marvin » Thu Apr 03, 2008 7:55 pm

Hope that option to allow fraction qty on Product settings will be included on the 0.8 release....  :)

Newbie

Posts

Joined
Tue Mar 25, 2008 10:35 am
Who is online

Users browsing this forum: No registered users and 3 guests