How do check whether a product variant option is unavailable

Topic summary

A developer is working on rendering product size options in a Shopify theme and needs to determine when a variant option is unavailable in order to disable the corresponding button.

Current Challenge:

  • The code uses option.values to iterate through available options
  • Need to check variant availability status to conditionally disable buttons
  • The provided code snippet appears corrupted or reversed, making the exact implementation unclear

Key Question:
How to programmatically check if a specific product variant option is unavailable in Shopify’s Liquid templating system?

Status: The question remains unanswered with no solutions or suggestions provided yet.

Summarized with AI on November 14. AI used: claude-sonnet-4-5-20250929.

I am trying to render the sizes for a product, and in the variants, if an option is unavailable, I want to disable the button, but how can I check if the variant option is unavailable?

{% for value in option.values %}
<option
  value="{{ value | escape }}"
  {% if option.selected_value == value %}selected="selected"{% endif %}
  {{ value }}
</option>
{% endfor %}

I will have to use option.values in this case and can’t switch to product.variants