I’m pretty new to shopify and I’m trying to get a
to only appear for a specific product variant. I thought I had it but it doesn’t seem to be working. I’m placing the code in a “Custom Code” section on a product page template. My theme is Palo Alto. Can someone tell me what I missed?
{% if selected_variant == '44637429661999' %}
{% endif %}
So what is {{ selected_variant }} in this case? That’s probably a reference to a variable. You need to find out what is getting assigned to that. And in any case, you’re trying to see if that is equal to the id of your variant. So lets just assume that selected_variant is product.selected_or_first_available_variant – you still need to reference the id
{% if selected_variant.id == '44637429661999' %}
{% endif %}
The “.id” reference is important.
Isn’t the id ‘44637429661999’?
It might be, but as you can see in the code you’re posting you’re not actually checking the .id property, you’re just using {{ selected_variant }}:
try checking selected_variant.id instead
Thank you so much for your help but unfortunately this did not work. =(