Objects / variant - is not working and data is not shown on the page

New Member
2 0 0


For some reason, I can't get any Object Variant variables on the page. It just not showing any data even a product contains two options with additional data.

I'm trying to get:

variant.option1 and variant.option2 for that I use code like this:

{{ variant.option1 }}


Any suggestion how can I get the Values of options on the product page?

The main goal what I want to achieve are generated unique meta description for some products by using option and other data from products. Currently, tested with other objects from the product ( https://help.shopify.com/themes/liquid/objects/product ) - I can get nearly everything from these data fields which contain any data, but can't get anything from Variant Objects.

Here is sample of my final snippet:

  {% if product.type contains 'Single' %}

	<meta name="description" content="Single Melt test. Option1 test: {{ variant.option1 }}. Proin eget tortor risus. Sed porttitor lectus nibh.">

	{% else %}
	<meta name="description" content="{{ page_description | escape }}">

  {% endif %}


Digital marketing experts: https://nzdmi.co.nz
Shopify Expert
9807 92 1560

Your Liquid isn't correct.

On a product page an object will be automatically available in liquid called product. There is however not a predefined variant object/variable. You need to make it.

For example:

{% assign variant = product.variants.first %}

^ that will get the first variant, or:

{% for variant in product.variants %}
  {{ variant.option1 }}
{% endfor %}

^ looping over each variant.

So for your example perhaps you want something like this:

<meta name="description" content="Single Melt test. Option1 test: {{ product.variants.first.option1 }}. Proin eget tortor risus. Sed porttitor lectus nibh.">


★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
1 Like
New Member
2 0 0

Thank you very much, Jason! It works as a charm! :)

Your explanation will help for the future stuff as well.

Digital marketing experts: https://nzdmi.co.nz
New Member
2 0 0

Not the same type of problem but maybe you can help me Jason.

I'm using the debut theme and went through the tutorial on having variant's selected in selector when clicking on it's picture... it seems to be working fine.

The only problem I can see is that instead of the selector saying "pick a color" or "pick a size" it says "pick a undefined" and I can't figure out how to have it choose the actual variant's name.

Any Ideas?


The tutorial is the 2 links at the bottom of this page.



39 2 0


solution is adding:

 var productOptions = [];
  {% for option in product.options %}
   var optionObj = {};
   optionObj[ {{ forloop.index0 }} ] = "{{ product.options[forloop.index0] }}";
  {% endfor %}

to product.template liquid