Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

SERACHING PRODUCT OPTIONS

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 05-07-2004, 05:37 PM
  daddyroy's Avatar 
daddyroy daddyroy is offline
 

Member
  
Join Date: Apr 2004
Location: Tallahassee, FL
Posts: 19
 

Default 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?????
Reply With Quote
  #2  
Old 05-07-2004, 06:57 PM
  daddyroy's Avatar 
daddyroy daddyroy is offline
 

Member
  
Join Date: Apr 2004
Location: Tallahassee, FL
Posts: 19
 

Default 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]
Reply With Quote
  #3  
Old 05-07-2004, 08:58 PM
  daddyroy's Avatar 
daddyroy daddyroy is offline
 

Member
  
Join Date: Apr 2004
Location: Tallahassee, FL
Posts: 19
 

Default GOT IT!!!!!

just changed =$sz to LIKE '%$sz%'. IT WORKS!!!!!!!!!!!! YES !!!!!!!
Reply With Quote
  #4  
Old 05-13-2004, 04:06 AM
 
xcell67 xcell67 is offline
 

Senior Member
  
Join Date: Dec 2003
Posts: 149
 

Default 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
Reply With Quote
  #5  
Old 05-13-2004, 06:34 AM
  daddyroy's Avatar 
daddyroy daddyroy is offline
 

Member
  
Join Date: Apr 2004
Location: Tallahassee, FL
Posts: 19
 

Default 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>
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 11:56 PM.

   

 
X-Cart forums © 2001-2020