X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   SERACHING PRODUCT OPTIONS (https://forum.x-cart.com/showthread.php?t=7489)

daddyroy 05-07-2004 05:37 PM

SERACHING PRODUCT OPTIONS
 
Hello, I contacted X-Cart and they said this was not possible, but I can't accept that! Well they actually said that I would have to purchase some additional thing from them. I THINK NOT!!! Anyway, I building a shoe store and I want customers to be able to search by size. All sizes are entered in the "product_options tabe. I look at the table and I saw the following:

xcart_product_options

productid
----------
16136


optclass
---------
Size


opttext
--------
Size


options
--------
6
7
7.5
8
8.5
9


So that gave me an idea so I tried the following query, but no results are returned:

Code:

$match ="7";
// the database query
$query = "SELECT * FROM $sql_tbl[products],$sql_tbl[product_options] WHERE forsale='Y' AND avail>0 AND $sql_tbl[products].productid LIKE $sql_tbl[product_options].productid AND $sql_tbl[product_options].options LIKE $match ORDER by xcart_products.product ASC LIMIT 0,20 ";


ANY SUGGESTIONS?????

daddyroy 05-07-2004 06:57 PM

THEY SAI IT COULDN'T BE DONE!! I DID IT, BUT..............
 
This is what I used to search my product options:

Quote:

// the database query
$query = "SELECT * FROM $sql_tbl[products],$sql_tbl[pricing],$sql_tbl[product_options] WHERE forsale='Y' AND avail>0 AND $sql_tbl[products].productid LIKE $sql_tbl[product_options].productid AND $sql_tbl[products].productid LIKE $sql_tbl[pricing].productid AND $sql_tbl[product_options].options=$sz ORDER by xcart_products.product ASC LIMIT 0,20 ";

$sz is the variable. THS WORKS.

The only problem is that it only searches the top line:

6
7
7.5
8

So the search will only find 6 and not 7 or 7.5 or 8, so I'm back at it again. [/b]

daddyroy 05-07-2004 08:58 PM

GOT IT!!!!!
 
just changed =$sz to LIKE '%$sz%'. IT WORKS!!!!!!!!!!!! YES :lol: :-({|= !!!!!!!

xcell67 05-13-2004 04:06 AM

Hi, question about your search for product options
 
Hi,
Whoo finally, someone figured out how to search for product options, THANK YOU. slight problem though:

where do I put this code:

Code:

Quote:
// the database query
$query = "SELECT * FROM $sql_tbl[products],$sql_tbl[pricing],$sql_tbl[product_options] WHERE forsale='Y' AND avail>0 AND $sql_tbl[products].productid LIKE $sql_tbl[product_options].productid AND $sql_tbl[products].productid LIKE $sql_tbl[pricing].productid AND $sql_tbl[product_options].options=LIKE '%$sz%' ORDER by xcart_products.product ASC LIMIT 0,20 


and you stated that the variable was $sz, I was wondering what that variable respresented is it the optclass or opttext?

Thanks for your time,
James

daddyroy 05-13-2004 06:34 AM

PRODUCT OPTIONS SEARCHING
 
"$sz" in my query is just short for size. This is because I'm using a "Search by Size" option.

See this post:

http://forum.x-cart.com/viewtopic.php?t=10157

Its the same concept the only thing that changes is the QUERY. It is what you define it to be:

For example if you were searching by the color "Red"

your query would be:

Code:

// the database query
$query = "SELECT * FROM $sql_tbl[products],$sql_tbl[pricing],$sql_tbl[product_options] WHERE forsale='Y' AND avail>0 AND $sql_tbl[products].productid LIKE $sql_tbl[product_options].productid AND $sql_tbl[products].productid LIKE $sql_tbl[pricing].productid AND $sql_tbl[product_options].options=LIKE '%$color%' ORDER by xcart_products.product ASC LIMIT 0,20 



You would access the query using:

http://www.your-store.com/catalog/customers/colors.php?color=red

or for green

http://www.your-store.com/catalog/customers/colors.php?color=green

.. and so on and so forth.


If you were using an option list were you select the different colors, you would usine the following form:

<form action="../customers/colors.php" method="GET">
<option selected value="">Select your color</option>
<option value="red">Red</option>
<option value="green">Red</option>
<option value="blue">Red</option>
<option value="black">Red</option>
</select>


All times are GMT -8. The time now is 05:58 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.