B
B
byms2014-10-25 13:14:58
Yii
byms, 2014-10-25 13:14:58

Change image when clicking on a color. How to implement?

You need to make sure that when you click on the color of the product, the picture changes. I have one idea, to make a table linked to a product with color and image fields, and when clicking on a color, load the image with Ajax. Would like to know if there are any other options?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
KorsaR-ZN, 2014-10-25
@byms

Your idea is correct, and that's usually how it's done.
The product has a color property, this property usually contains several parameters: icon, name, pictures, article (if it changes from color), price or markup (if it depends on color)

I
Igorrebega, 2014-10-25
@Igorrebega

You can just name the file in which all the pictures are at once (for example, one under one) and then when you click using js, just change the background-position

X
xmoonlight, 2014-10-25
@xmoonlight

optimal: 1 product - 1 color.
If there are several colors, you make cross-references: squares with colors on click -> go to another product page (the same name, but with a different color).
1. Not all reviews, etc. for goods of one color are valid for another!
2. Get rid of the confusion when generating YML and the like
3. Indexing (SEO)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question