Simple string comparison

My string comparison seems not to be working, the variation_name doesn’t get printed to the screen whether the value of variation_name is “Main” or “Other” <% if ! products_variations_option.variation_name == “Main” %> <%= products_variations_option.variation_name %>
<% end %>

String comparison is probably working. Check that this part of the template is output at all. You can also see what you have in variation_name by adding this to your template

<%= debug products_variations_option.variation_name %>

Paste more code if you still cannot find the issue.

It’s not working because you try to negate products_variations_option.variation_name first with the ! that is in front. For example:

>> !'something'
=> false

So you are comparing false with 'Main'

1 Like