Hello Shopify Community,
I’m currently editing a clothing-based Shopify site that has uses two options containing different variant buttons. I want colors and sizes to be disabled or “greyed out” when they are not available. If I have a product with only one option, the variants are “greyed out” but as soon as I create a product with two options (see example below) the"greyed out" feature fails to work.
E.g.
Option 1:
-
White
-
Black
-
Yellow
Option 2:
-
Small
-
Large
-
Medium
For more context, the variant buttons use the following code from a file called variant-button.liquid
{%- for value in option.values -%}
{%- assign product_available = true -%}
{%- if product.options.size == 1 -%}
{%- assign product_available = product.variants[forloop.index0].available -%}
{%- endif -%}
{%- if is_color -%}
{%- assign color_image = value | handle | append: '.' | append: swatch_file_extension | asset_img_url: '50x' | prepend: 'https:' | split: '?' | first -%}
{%- assign color_swatch_fallback = value | split: ' ' | last | handle -%}
{%- else -%}
{%- endif -%}
From my limited research, it seems the issue is because the options don’t talk to each other and liquid cannot handle this type of logic (because the variants would need to refresh when a new variant button is selected). I’m assuming we would need to use JS and query selectors to build this function. Since Shopify moved to store 2.0, I have not been able to find any solutions up to date. If you are looking to help tackle this problem with me, please help in this discussion forum (:
Thanks to anyone who takes time out of their day to help a fellow developer out!!!







