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

Basic color swaping swatches

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 07-17-2006, 12:14 PM
 
sstillwell@aerostich.com sstillwell@aerostich.com is offline
 

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

Default Basic color swaping swatches

Ok,

I get several requests on how to do the swapping as found on this page
http://www.aerostich.com/product.php?productid=16376&cat=248&page=1

It's pretty simple, so I'll spell it out. You will need to have a little understanding of HTML to implement this.

First you need to create images that are exactly alike except for color. In my case I created blue, black, red, grey, yellow. Then name them accordingly, DarienBlue.jpg, DarienBlack.jpg.... Put these images somewhere on your server e.g. /files/images/suits

Keep the order of your colors consistent

Second, you need to create the javascript and include it in the page. Add the following into /skin1/customer/common.js
Code:
// Code for the Darien to switch colors // Selects the proper color in the drop down color menu function ChangeDarienColor(id,newValue) { var colorCodes = new Array("Blue","Black","Red","Gray","Viz","Silver"); // Change the correct drop down menu if(id!=""){ document.getElementById(id).selectedIndex = newValue; } // Change the image var ImageName = "Darien"+colorCodes[newValue]+".jpg"; document.getElementById("ColorfulSuitD").src = "/files/images/suits/"+ImageName; }
right before the
Code:
-->

The basic HTML looks like this. You will have to ediit it for two things. 1. the colors. 2. the id of your selection (notice that clicking the swatch changes the drop down selection as well.).

Code:
<table width="100%" cellpadding="0" cellspacing="0"> <tr> <td valign="top"> Standard Colors (click to view) <table> <tr> <td> <table style="border: 1px solid #FFFFFF;" cellpadding="2" onmouseover="javascript:this.style.borderColor = '#2E2930';" onmouseout="javascript:this.style.borderColor = '#FFFFFF';"> <tr> <td width="20" style="background-color: blue;" onClick="ChangeDarienColor('po81','0')"> </td> </tr> </table> </td> <td> <table style="border: 1px solid #FFFFFF;" cellpadding="2" onmouseover="javascript:this.style.borderColor = '#2E2930';" onmouseout="javascript:this.style.borderColor = '#FFFFFF';"> <tr> <td width="20" style="background-color: black;" onClick="ChangeDarienColor('po81','1')"> </td> </tr> </table> </td> <td> <table style="border: 1px solid #FFFFFF;" cellpadding="2" onmouseover="javascript:this.style.borderColor = '#2E2930';" onmouseout="javascript:this.style.borderColor = '#FFFFFF';"> <tr> <td width="20" style="background-color: red;" onClick="ChangeDarienColor('po81','2')"> </td> </tr> </table> </td> <td> <table style="border: 1px solid #FFFFFF;" cellpadding="2" onmouseover="javascript:this.style.borderColor = '#2E2930';" onmouseout="javascript:this.style.borderColor = '#FFFFFF';"> <tr> <td width="20" style="background-color: gray;" onClick="ChangeDarienColor('po81','3')"> </td> </tr> </table> </td> <td> <table style="border: 1px solid #FFFFFF;" cellpadding="2" onmouseover="javascript:this.style.borderColor = '#2E2930';" onmouseout="javascript:this.style.borderColor = '#FFFFFF';"> <tr> <td width="20" style="background-color: #ebe805;" onClick="ChangeDarienColor('po81','4')"> </td> </tr> </table> </td> </tr> </table> </td> <td valign="top">[img]/files/images/suits/DarienBlue.jpg[/img]</td> </tr> </table>

In my case, the ID of the selection is "po81".

That's basically it in a nutshell. There is another more complex form of this for a different product we sell, but that includes the use of hidden form elements to keep track fo selected colors. It 's for this product.
http://www.aerostich.com/product.php?productid=16133&cat=248&page=1

But that is more complex and I won't explain it here.

If you have questions just ask them here, I or someone else may be able to point you in the right direction, but before you dive head long into Javascript, CSS, and HTML, it's best to arm yourself with some knowledge about it. Have fun.
__________________
No longer using Xcart, was good while it lasted.
Reply With Quote
  #2  
Old 09-08-2006, 11:42 PM
 
larrydavidow larrydavidow is offline
 

Advanced Member
  
Join Date: Feb 2005
Posts: 38
 

Default Re: Basic color swaping swatches

This mod is for 4.1 only right?
__________________
X-Cart Gold
4.5.4
Reply With Quote
  #3  
Old 09-14-2006, 09:42 AM
 
sstillwell@aerostich.com sstillwell@aerostich.com is offline
 

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

Default Re: Basic color swaping swatches

Actually,

If you look at my signature. This is mod is for 4.0.12, but should work in most versions as it doesn't really depend on the Xcart structure to make it happen.
__________________
No longer using Xcart, was good while it lasted.
Reply With Quote
  #4  
Old 09-19-2006, 12:56 PM
 
gfiebich gfiebich is offline
 

Senior Member
  
Join Date: Feb 2003
Location: St. Paul, MN
Posts: 108
 

Default Re: Basic color swaping swatches

Thanks for sharing this. I like the fact that clicking a swatch updates the selected color option. Have you had any luck making this work in reverse? Ie. changing the selected color option updates the product image?
__________________
NO LONGER USING X-CART - NOT ACTIVE IN THESE FORUMS
Reply With Quote
  #5  
Old 09-19-2006, 01:16 PM
 
sstillwell@aerostich.com sstillwell@aerostich.com is offline
 

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

Default Re: Basic color swaping swatches

I don't have it set up to do it in reverse, but check out this Xcart install. This guys has it done. You may want to ask him.

http://www.horseloverz.com/Soft-Stretch-Elastic-Lead-Rope-pr-178626.html
__________________
No longer using Xcart, was good while it lasted.
Reply With Quote
  #6  
Old 10-08-2006, 07:25 AM
 
iblazed iblazed is offline
 

Newbie
  
Join Date: Jul 2006
Posts: 7
 

Default Re: Basic color swaping swatches

I really would like to get this mod working but I am having a little trouble. Where is it that I put the basic HTML code? Also where do I get the id of my selection? Thanks for any help.
__________________
X-Cart version 4.1.2
Reply With Quote
  #7  
Old 10-09-2006, 03:13 AM
 
sstillwell@aerostich.com sstillwell@aerostich.com is offline
 

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

Default Re: Basic color swaping swatches

Quote:
Originally Posted by iblazed
I really would like to get this mod working but I am having a little trouble. Where is it that I put the basic HTML code? Also where do I get the id of my selection? Thanks for any help.

The basic HTML goes in the product description. The id of the selection can be seen when you view source at the product page (customer side), it will be "poXX"
__________________
No longer using Xcart, was good while it lasted.
Reply With Quote
  #8  
Old 11-07-2006, 11:36 AM
 
speesees speesees is offline
 

Newbie
  
Join Date: Oct 2006
Posts: 4
 

Default Re: Basic color swaping swatches

Is there a way to dynamically get the poXX? I have many different advanced variants and ID is unique. Once I get the code working for one like po81, on another page the same option menu is po102, etc.

Or can one target the first advanced variant without knowing what it's poXX ID is? If I always use the same type of Advanced Variant as the first option, then I could target it consistenly in my own code add-on.
__________________
4.1.3
Reply With Quote
  #9  
Old 12-02-2006, 01:06 PM
 
andreas04031 andreas04031 is offline
 

Advanced Member
  
Join Date: Jun 2004
Location: Dallas, TX
Posts: 64
 

Default Re: Basic color swaping swatches

I love that mod, got it working on my 4.1.3 testshop and put it live pretty soon, thank you very much!!!
Andy
__________________
X-Cart version 3.5.9 (online)
X-Cart Version 4.0.19 (online)
X-Cart Version 4.1.3 (in dev)
PHP 4.4.4
MySQL 4.1.21
Reply With Quote
  #10  
Old 12-20-2006, 11:06 AM
 
ryan c. ryan c. is offline
 

Advanced Member
  
Join Date: Sep 2002
Posts: 58
 

Default Re: Basic color swaping swatches

Am I missing something? I can not find skin1/customer/common.js anyhwhere?
__________________
Version 4.1.8
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:43 AM.

   

 
X-Cart forums © 2001-2020