Thank you so much for this snippet! It worked perfectly for me.
Would you know how to get it to display a shortened version of the variant? Ex: “Small” → “S”
I tried using {% if variant.options == “small” | replace: “small”, “S” %} or {% if variant.options contains “small” | replace: “small”, “S” %} but it didn’t work.