How to change 'Sold Out' status to when ALL variants are sold out not just the 1st

Products are showing as sold out when the 1st option is out of stock but there is availability for the others. How do I change it so that it only displays sold out when all variants are sold out?

I have found similar questions on the community, but I don’t seem to have the same code as any of these so haven’t been able to implement any of the suggestions.

I am using Dawn theme and the only file I have found that mentions the sold out message is card-product.liquid and this is what it contains that I think is relevant?

{% assign product_form_id = 'quick-add-' | append: section_id | append: card_product.id %} {% if quick_add == 'standard' %}
{%- liquid assign qty_rules = false if card_product.selected_or_first_available_variant.quantity_rule.min > 1 or card_product.selected_or_first_available_variant.quantity_rule.max != null or card_product.selected_or_first_available_variant.quantity_rule.increment > 1 assign qty_rules = true endif -%} {%- if card_product.variants.size > 1 or qty_rules -%} {{ 'products.product.choose_options' | t }} {%- if horizontal_quick_add -%} {{- 'icon-arrow.svg' | inline_asset_content -}} {%- endif -%} {%- render 'loading-spinner' -%}
{{- 'icon-close.svg' | inline_asset_content -}}
{%- else -%} {%- form 'product', card_product, id: product_form_id, class: 'form', novalidate: 'novalidate', data-type: 'add-to-cart-form' -%} {%- if card_product.selected_or_first_available_variant.available -%} {{ 'products.product.add_to_cart' | t }} {%- else -%} {{ 'products.product.sold_out' | t }} {%- endif -%} {{ 'products.product.sold_out' | t }} {%- if horizontal_quick_add -%} {{- 'icon-plus.svg' | inline_asset_content -}} {%- endif -%} {%- render 'loading-spinner' -%} {%- endform -%} {%- endif -%}
{% elsif quick_add == 'bulk' %} {% if card_product.variants.size == 1 %} {% if card_product.selected_or_first_available_variant.available == false %} {{ 'products.product.sold_out' | t }} {{ 'products.product.sold_out' | t }} {% else %} {% render 'quantity-input', variant: card_product.selected_or_first_available_variant, min: 0 %} {% endif %} {% else %}
{%- liquid assign product_form_id = 'quick-add-' | append: section_id | append: card_product.id assign qty_rules = false if card_product.selected_or_first_available_variant.quantity_rule.min > 1 or card_product.selected_or_first_available_variant.quantity_rule.max != null or card_product.selected_or_first_available_variant.quantity_rule.increment > 1 assign qty_rules = true endif -%}

Please try this updated code.


Hey @RC-M ,

The product card is checking for availability using card_product.selected_or_first_available_variant.available, which means it’s only checking if the first variant is available.

Here’s the solution:

{% comment %}
Step 1: Find the card-product.liquid file in your theme's snippets directory
Step 2: Locate the current logic that determines if a product is sold out
Step 3: Replace it with this improved version that checks all variants
{% endcomment %}

{% comment %}
Add this code at the top of your card-product.liquid file, before the product card markup
{% endcomment %}

{% assign all_variants_sold_out = true %}
{% for variant in card_product.variants %}
  {% if variant.available %}
    {% assign all_variants_sold_out = false %}
    {% break %}
  {% endif %}
{% endfor %}

{% comment %}
Then, find any instances where it checks for product availability like this:
card_product.selected_or_first_available_variant.available 

And replace them with your new all_variants_sold_out variable (with inverted logic since it's tracking if ALL are sold out)
{% endcomment %}

{% comment %}
For example, replace this code:
{% endcomment %}

{% else %}
{% render 'quantity-input', variant: card_product.selected_or_first_available_variant, min: 0 %}
{% endif %}

The solution works by:

  • Creating a variable all_variants_sold_out that starts as true
  • Looping through all product variants to check if any are available
  • If at least one variant is available, setting the variable to false
  • Using this variable instead of just checking the first variant’s availability

This way, the “Sold Out” label and button state will only appear when all variants are truly unavailable, not just when the first variant is out of stock.

After making these changes, save the file and your product cards should now properly show “Sold Out” only when all variants are unavailable.

Feel free to reach out if you’ve any more questions for me.

Cheers!
Shubham | Untechnickle

Thank you for your suggestion. I tried your code but it didn’t seem to change anything. I’ve attached the entire card-product incase you can see anything else to suggest

Thank you so much for taking the time to explain. I’ve tried all of the above but it doesn’t seem to change anything. I’m attaching the entire card-product code incase you have any other suggestions