How to display text based on product variant option?

I’m looking for some help with displaying some help text next to each product label/variant, so depending on the variant option, it shows a tooltip for that product option with the relevant text. We have added the icon in and it all works we just need help with the code to display specific text based on the variant. Here’s what we have so far:

{%- when 'select' -%}

What i need is help with the code that will display text, so for example, if option is Screen Size then we display this text “The size of the screen will depend on stock” or if the option is Length then we display this text “We have many lengths available, call us for more details” and so on and so on.

Thanks for any help.

Hi @always-develop ,

You can add conditions here:

Code:

{%- if option.name == 'Screen Size' -%}
  

(The size of the screen will depend on stock)

{%- elsif option.name == 'Length' -%}
  

(We have many lengths available, call us for more details)

{%- endif -%}

Hope it helps!

Where am i need to put this code? Have no experience in coding but need to do the same thing in my shop

Let me help you?

1 Like