How do I add a sold out badge to pictures when all variants are sold out?

How do I add a sold out badge to pictures when all variants are sold out? The badge shows on the picture in the collection section for items that do not offer variants, however it will not display on sold out items which offer variants even when all variants are sold out. I have been told coding is more than likely needed. Does anyone know the fix?

Hi, yes this can be done by modifying the code
you can use this code to check the condition and add sold badge

{% if product.variants.size == 1 and product.variants.first.inventory_quantity == 0 %}
  
  Sold Out
{% endif %}

Hi, Thank you for replying. Where can I check and add this code?

It depends on your theme every theme has different fille names
you can check this in collection.liquid or any other similar named file

Hi @ang17 ,

If you encounter difficulties adjusting the code, you can use the Product Labels & Badges app following these steps:

Step 1: Install and enable the embed app

Step 2: Create a text label with the content “sold out”

Step 3: Go to Product Settings and choose “Out stock” under Inventory status.

Step 4: Navigate to General Settings and select to show on collection pages.

If you experience any issues with the display, you can contact the support team via live chat. They’re always ready to assist you in successfully setting up your labels and badges. :hugs:

Thanks for your reply, unfortunately I have unsuccessful in locating this folder

Hi, I am using a Minimog theme. Do you know where I can find the folder?

I am using minimog theme, do you know where I can find?