How can I hide sold out opiton values/variants ?

Topic summary

A user is seeking help to hide sold-out product variants/option values on their Shopify store’s product page.

Current Implementation:

  • The provided code includes basic product display logic with images, videos, pricing, and availability checks
  • Shows “sold out” or “coming soon” messages when products are unavailable
  • Contains form elements for product options and quantity selection

The Problem:
The code doesn’t currently filter out sold-out variants from the option selector—all variants remain visible regardless of inventory status.

Status:
No solutions have been provided yet. The discussion remains open with the original poster awaiting guidance on how to conditionally hide unavailable option values from the variant selector.

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

I am struggling to hide the sold out variants/option values. Does someone know how to do it ? This is the code of my productpage so far.


    

        {% for image in product.images %}
            
        {% endfor %}

        {% for media in product.media %}
            {% if media.media_type == 'video' %}
              {{ media |  video_tag: autoplay: true, loop: true, muted: true, controls: true  }}
            {% endif %}
          {% endfor %}
    

        
    

    
        

            # {{ product.title }}
            

{{product.price | money }}

            

inkl. MwSt

            {% if product.available == false %}
                {% if product.type == 'comming soon' %}
                    

comming soon!

                {% else %}
                

sold out!

                {% endif %}
            {% endif %}
        

        {% if product.available %}
        

            {% form 'product', product %}

                

    
                

                    {% for option in product.options_with_values %}
                        
                    {% endfor %}
                    
                

        
                
                    

                        
                        

+

                    

    
                    
                        
                        

$

                    

                

                
            {% endform %}

        

            {% else %}
            {% if product.type == 'comming soon' %}
                

Der Artikel ist bald Verfügbar !

            {% else %}
            

dieser Artikel ist leider Ausverkauft!

            {% endif %}    
        {% endif %}
        
        
        
            {{ product.description }}