Adding SOLD OUT opaque button to Collection grid when product is sold out

Topic summary

A user is trying to implement a “SOLD OUT” button on their Shopify Collections page that matches the behavior on Product Pages—displaying as grey and reading “SOLD OUT” when products are unavailable.

Current Issue:

  • The functionality works on Product Pages but not on the Collections grid
  • The user can’t locate where to reference the code in the Collection Page

Attempted Solutions:

  • Multiple support representatives requested the grid-item.liquid file code
  • One provider offered a code snippet but noted it needs adjustment based on the specific theme
  • Another suggested a code modification involving conditional logic ({% if sold_out %} / {% else %} / {% endif %})

Code Shared:
The user provided their grid-item.liquid file, which includes existing sold-out logic and badge display settings. The code appears reversed/garbled in the thread, suggesting formatting issues.

Status: The discussion remains ongoing with troubleshooting in progress. A specific code change was recommended but implementation results haven’t been confirmed.

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

I added the ability to add a product from the Collections page, and I want that button to have the same behavior as in Product Pages when it’s sold out: the button turns grey and reads “SOLD OUT”.

I can’t get this to work on the Collections page (see images below).

I can’t find this code in the Product Page, so not sure how to reference it in the Collection Page. Thanks

Hi @LucasSoler ,

Please send me the code of product-grid-item.liquid file, I will check it for you

Hi @LucasSoler

I would like to give you a code snippet for the SOLD OUT case for the theme. You can refer to it and adjust it to your theme because the code on themes is different:


I hope that it’s useful to you!

Here you go, thanks.

{% comment %}###### Lucas: Page used for displaying product details within Collections page###### Nov 21 2022: Adding ability to remove “add to harvest basket” button when Product Type includes “arriving soon”###### {% endcomment %}
{% unless current_collection == blank %}###### {% assign current_collection = collection %}###### {% endunless %}
{% assign on_sale = false %}###### {% assign sale_text = ‘products.product.sale’ | t %}###### {% if featured.compare_at_price > featured.price %}###### {% assign on_sale = true %}###### {% endif %}
{% assign sold_out = true %}###### {% assign sold_out_text = ‘products.product.sold_out’ | t %}###### {% if featured.available %}###### {% assign sold_out = false %}###### {% endif %}
{% if featured.title == ‘’ %}###### {% comment %}add default state for product block in storefront editor{% endcomment %}###### {% capture product_title %}{{ ‘home_page.onboarding.product_title’ | t }}{% endcapture %}###### {% else %}###### {% capture product_title %}{{ featured.title | escape }}{% endcapture %}###### {% endif %}
{% include ‘image-style’ with image: featured.featured_image, width: product_width, height: 480, wrapper_id: wrapper_id, img_id: img_id %}######
######
###### <img id=“{{ img_id }}”###### alt=“{{ featured.featured_image.alt | escape }}”###### class=“product__img lazyload”###### data-src=“{{ img_url }}”###### data-widths=“[150, 220, 360, 470, 600, 750, 940, 1080, 1296, 1512, 1728, 2048]”###### data-aspectratio=“{{ featured.featured_image.aspect_ratio }}”###### data-sizes=“auto”###### data-image>######
######
###### {% else %}###### {{ featured.featured_image.alt | escape }}###### {% endunless %}###### ###### {{ featured.featured_image.alt | escape }}###### ###### {% else %}###### {% capture current %}{% cycle 1, 2, 3, 4, 5, 6 %}{% endcapture %}###### {{ ‘product-’ | append: current | placeholder_svg_tag: ‘placeholder-svg’ }}###### {% endif %}###### ###### ######

{{ product_title }}

###### ###### ###### ###### {% comment %}Start automatically added Judge.me widget{% endcomment %}###### {% render ‘judgeme_widgets’, widget_type: ‘judgeme_preview_badge’, concierge_install: true, product: product %}###### {% comment %}End automatically added Judge.me widget{% endcomment %}
###### ###### {% if section.settings.vendor_enable %}######

{{ featured.vendor }}

###### {% endif %}
###### ###### ###### ###### {% if featured.title != ‘’ %}######

###### {%- assign price = featured.price | money -%}

{% if on_sale %}###### {{ ‘products.product.regular_price’ | t }}###### {{ featured.compare_at_price | money }}###### {% endif %}###### {% if featured.price_varies %}###### {{ ‘products.general.from_html’ | t: price: price }}###### {% else %}###### {% if on_sale %}###### {{ ‘products.product.sale_price’ | t }}###### ###### {% else %}###### {{ ‘products.product.regular_price’ | t }}###### {% endif %}###### {{ price }}
###### {% if on_sale %}###### {% comment %} Lucas: display savings if on sale, May 2021 {% endcomment %}###### ###### savings: {{ product.compare_at_price | minus: product.price | money }}###### {% endif %}###### ###### ###### ###### {%- assign variant = featured.selected_or_first_available_variant -%}###### {%- if variant.available and variant.unit_price_measurement -%}###### {% include ‘product-unit-price’, variant: variant, wrapper_class: ‘grid-link__unit-price’ %}###### {%- endif -%}###### ###### {% endif %} ######

###### {% endif %} ######
###### ###### ###### {% comment %}###### Lucas: Feb 25, 2022, adding Add to Harvest Basket buttons to Collection page###### Lucas: Nov 21,2022: don’t display “add to Harvest Basket” button if Product Type includes “arriving soon”###### {% endcomment %}
###### {% if product.type contains “arriving soon” %}###### {% comment %} don’t display “add to harvest basket” {% endcomment %}
{% else %}###### ###### ###### ###### ###### ###### ###### ###### {% endif %}###### ###### ###### ###### ###### ###### ###### ######

Code pasted.

Hi @LucasSoler ,

Please change code here:

Code:

{% if sold_out %}
    
{% else %}
    
{% endif %}

Hope it helps!