I need help for getting colour variant value

Highlighted
Shopify Partner
10 0 0

Hey Everyone, I need urgent help please

I want to achieve something like

{% if product.option.value == White %}

some code here

{% else %}

other code

{% endif %}

but I am unable to do that, I want when user select color variant value white I want to show all  white images in thumbnail and if blue color then all blue images, i have code ready for images and I can implement it but the issue is I am unable to set the condition for White and Blue color selected, any help highly appreciated

I need urgent please

Many Thanks

Babar

0 Likes
Highlighted
Shopify Partner
1457 174 268

First of the value should be a string:

 

{% if product.option.value == 'White' %}

some code here

{% else %}

other code

{% endif %}

Second, is product a variant? Or the product? I think you should be getting the selected variant first and then check the value of the option. It depends, if Color is the first option, then it should be something like:

 

{% if variant.option1 == 'White' %}

some code here

{% else %}

other code

{% endif %}

 

 

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
1 Like
Shopify Partner
10 0 0

Thanks so much for the quick reply but I tested both the codes and no one is working for me after implementing the code when I execute both gave me same result which was "other code", when I selected white colour it showed output "other code " and when I selected Nude Colour it showed same output "Othercode", I am attaching snapshots please help Thanks so much

nude.PNGwhite.PNGnude.PNG

0 Likes
Highlighted
Shopify Partner
1457 174 268

Is variant selection AJAX based? Looks like it is, in this case you'll not be able to fix it using just liquid code, unless the page refreshes after each variant selection. Can you share a preview URL to your store? You can direct message it to me.

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
Highlighted
Shopify Partner
10 0 0

@Visely-Team 

Product with name "Short sleeve undershirt white" has multiples colors

https://finn-design.de/products/herren-unterhemd-kurzarm-weiss?variant=2504953036829

waiting for the quick reply Thanks for the help

0 Likes