Zen Cart Logo
Forums / General Questions / How do I add a dropdown for product selection?

How do I add a dropdown for product selection?

Views: 1,170

Results 1 to 5 of 5
24 May 2010, 5:51 AM
#1
mikecass avatar

mikecass

New Zenner

Join Date:
Sep 2004
Posts:
27
Plugin Contributions:
0

How do I add a dropdown for product selection?

Hi,

I'm trying to add a drop down to the categories sidebox that will allow a user to see a) all stock, b) Only items in stock, or c) only out of stock items. Once the selection is set it needs to stay selected, until changed by the user.

This needs to affect the categories list, and the all the methods to display products.

Not an easy task, any help would be appreciated.

Thank you,
Mike Cassidy

24 May 2010, 7:21 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: How do I add a dropdown for product selection?

Not an easy task, any help would be appreciated.
Yes correct and far too complex for a forum solution...
Try posting in the commercial help wanted are here on this forum

24 May 2010, 10:47 AM
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How do I add a dropdown for product selection?

Set a $_SESSION variable such as:

$_SESSION['stock_quantity status']

where 2 is out of stock ... and 1 is in stock ... and 0 for All ...

Then change the SELECT to use for in stock:
products_quantity >= $_SESSION['stock_quantity status']

and for out of stock:
products_quantity <= 0

and for all products, where $_SESSION['stock_quantity status'] = 0, just do not add the condition to the SQL statements ...

I usually will build a peice for the SQL statement such as:
switch ($_SESSION['stock_quantity status']) {
case (2):
$stock_quantity_status = ' and products_quantity <= 0 ';
break;
case (1):
$stock_quantity_status = ' and products_quantity >= 1';
break;
default:
$stock_quantity_status = '';
break;
}

You can then use this where you need it ...
The Case statement then lets you tack on to the SQL the:
$stock_quantity_status

as it will either contain the filter or be blank ...

29 May 2010, 6:01 AM
#4
mikecass avatar

mikecass

New Zenner

Join Date:
Sep 2004
Posts:
27
Plugin Contributions:
0

Re: How do I add a dropdown for product selection?

Thank you Linda, you always come through for me!

29 May 2010, 9:48 AM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How do I add a dropdown for product selection?

You are most welcome ... glad that this was able to work for you on filtering by quantity ...