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

change product on drop down select

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 03-31-2005, 09:48 PM
 
Gibberish Gibberish is offline
 

Senior Member
  
Join Date: Sep 2003
Posts: 182
 

Default change product on drop down select

I created this for a site I am doing and I thought I would post it for anyone looking to do the same since I could not find it posted here.

What I have is t-shirts that are the exact are same type just either a differnet size or a different color. So I created a dynamically populated drop down system on the product detail that shows the colors and sizes available for the current product and on select of a new color or size the page updates to the new product.

It's pretty simple. This is all assuming you have a field named 'size' that has the value of (small, medium,large,etc) and a field color with all or any colors (Black, White, Blue, Read, etc). These are both varchar fields in my products table.

This was done on version 4.0.9

Add this to your product.php page anywhere after line 50 (on unmodded product.php)
Code:
$vCategory = $product_info["categoryid"]; $vProduct = $product_info["product"]; $vColor = $product_info["color"]; $vSize = $product_info["size"]; # # Get all sizes # $all_sizes = func_query("SELECT DISTINCT $sql_tbl[products].productid, size FROM $sql_tbl[products] INNER JOIN $sql_tbl[products_categories] USING (productid) WHERE product = '$vProduct' AND categoryid = '$vCategory' AND color = '$vColor'"); $smarty->assign("all_sizes", $all_sizes); # # Get all colors # $all_colors = func_query("SELECT DISTINCT $sql_tbl[products].productid, color FROM $sql_tbl[products] INNER JOIN $sql_tbl[products_categories] USING (productid) WHERE product = '$vProduct' AND categoryid = '$vCategory' AND size = '$vSize'"); $smarty->assign("all_colors", $all_colors);

Place these in customer/main/product.tpl - anywhere you want them to show on the page.

Size Drop down:
Code:
<SELECT name="product_sizes" class="InputWidth" onChange="self.location=this.options[this.selectedIndex].value"> {section name=size_num loop=$all_sizes} <OPTION value="product.php?productid={$all_sizes[size_num].productid}&cat={$cat}"{if $product.size eq $all_sizes[size_num].size} selected{/if}>{$all_sizes[size_num].size}</OPTION> {/section} </SELECT>

Color drop down:
Code:
<SELECT name="product_colors" class="InputWidth" onChange="self.location=this.options[this.selectedIndex].value"> {section name=color_num loop=$all_colors} <OPTION value="product.php?productid={$all_colors[color_num].productid}&cat={$cat}"{if $product.color eq $all_colors[color_num].color} selected{/if}>{$all_colors[color_num].color}</OPTION> {/section} </SELECT>

I hope this helps someone.
__________________
Gibberish
[Unix] X-Cart 4.0.12
Reply With Quote
  #2  
Old 04-01-2005, 05:27 AM
 
sstillwell@aerostich.com sstillwell@aerostich.com is offline
 

eXpert
  
Join Date: Jun 2004
Location: Duluth, MN
Posts: 242
 

Default

Do you have an example URL that would help us visuallize what this would look like.
__________________
No longer using Xcart, was good while it lasted.
Reply With Quote
  #3  
Old 04-01-2005, 08:30 AM
 
Gibberish Gibberish is offline
 

Senior Member
  
Join Date: Sep 2003
Posts: 182
 

Default

I will next weekend when the site goes live. I will be sure to post a URL.
__________________
Gibberish
[Unix] X-Cart 4.0.12
Reply With Quote
  #4  
Old 04-04-2005, 03:05 PM
 
sgonyou sgonyou is offline
 

Newbie
  
Join Date: Dec 2004
Posts: 4
 

Default Image change

Quote:
Originally Posted by sstillwell@aerostich.com
Do you have an example URL that would help us visuallize what this would look like.

I love the site and the image roll overs. Is that custom code you wrote in order to have the clothes changes colors? Like red, black, blue etc... and it changes the big image.

That is exactly what ive ben looking for. Did you write that? If so, do you sell the code?

Thanks\\SG
__________________
Steve G
Reply With Quote
  #5  
Old 09-15-2005, 09:47 AM
 
danbass danbass is offline
 

Member
  
Join Date: Mar 2005
Posts: 13
 

Default

Was this going to be posted eventually? Hopefully?


Quote:
Originally Posted by Gibberish
I will next weekend when the site goes live. I will be sure to post a URL.
__________________
Dan
XCart 4.1.6 Pro
XCart 4.1.6 Gold
Redhat 7.2
Perl 5.006001
PHP 4.1.2
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 05:45 AM.

   

 
X-Cart forums © 2001-2020