Limited quantity

Ch

No avatar

2005-08-19 16:02

Hi,

how can I limit the value for the quantity, e.g. to a max of 2?

Thanks for support!

Ch

wewior (OpenSolution)

Avatar: wewior

2005-08-19 22:47

how? in javascript or php?

Ch

No avatar

2005-08-19 22:58

I'm open, what is easier...?
I'm tried the following:

I replaced in the file orders_basket.tpl the quantity entry:
<input type='text' name='aQuantity[]'...

with:
<select name="aQuantity[]" size="1" >
<option value="1" <?php if ($aBasket[iQuantity] == '1' )
{echo "SELECTED";} ?>>1</option>
<option value="2" <?php if ($aBasket[iQuantity] == '2' )
{echo "SELECTED";} ?>>2</option>
</select>

... but it doesn't work.

Any other idea? Thanks for support!

Christian

wewior (OpenSolution)

Avatar: wewior

2005-08-22 08:06

try to change function addBasketProduct in file core/orders.php to

function addBasketProduct( $iProduct, $iQuantity ){
$aProduct = throwProduct( $iProduct );
if( isset( $aProduct ) ){
if( $iQuantity > 2 )
$iQuantity = 2;
$iOrder = throwOrdersIdTemp( $_SESSION['iCustomer'] );
dbAddBasketProduct( $aProduct, $iQuantity, $iOrder );
}
} // end function addBasketProduct

i think it will work

Ch

No avatar

2005-08-22 20:16

Hi wewior,

thanks for your respond & proposal. I tried this adaption with the following result:

If I have in the cart the quantity of 1 and I try to overwrite the quantity with 5 the result is 3. I can add values to the quantity in steps with a max of 2.
But my goal is the have a absolute max. quantity of 2. Any idea?

Thanks!

Christian

wewior (OpenSolution)

Avatar: wewior

2005-08-23 10:06

function dbAddBasketProduct in core/orders-ff.php
change line:
$aFile[$i] = $aExp[0].'$'.$aExp[1].'$'.$aExp[2].'$'.sprintf( '%01.0f', $aExp[3] + $iQuantity ).'$'.$aExp[4]."$\n";
to
$iQuantityAll = sprintf( '%01.0f', $aExp[3] + $iQuantity );
if( $iQuantityAll > 2 )
$iQuantityAll = 2;
$aFile[$i] = $aExp[0].'$'.$aExp[1].'$'.$aExp[2].'$'.$iQuantityAll .'$'.$aExp[4]."$\n";
i dont test it but i think it will work fine

Ch

No avatar

2005-08-23 20:41

Hi wewior,

thanks for the solution! It works fine. The background for your information: I need this function due to the fact, that the delivery costs are independent from the quantitiy. If I have to deliver up to a quantity of 6 the delivery price will be the same...

For my easy shop it is absolutely ok to have only one quantity-limitation for all products (less amount).

Greeting from Germany...

Christian

Ch

No avatar

2005-08-24 21:16

ohh... now I have found a problem...
If the basket is empty... and I go to the products...Then I press a product image and enter a quantity of 999... the basket takes over this quantity of 999.

Coul'd you help? Thanks

Christian

wewior (OpenSolution)

Avatar: wewior

2005-08-25 10:13

give mi some link so i can see it

Ch

No avatar

2005-08-29 21:57

Hi wewior, sorry for my late response... I have no site running up in the moment - I use only my local server for testing... the live system should start in the next days...

As interims solution I marked the following row as mark:
$lang[Quantity]...
line 57-59
file: templates/default/products_show.tpl

Not perfect, but now it work's fine.

Christian

Back to top
about us | contact