How can I hide out-of-stock items in collections with code?

Hello,

Can you help me how to hide out of stock items in collections?

Best,

JP

@JPCancino

Sorry you are facing this issue, it would be my pleasure to help you.

Welcome to the Shopify community! :blush:
Thanks for your good question.

Please share your site URL,
I will check out the issue and provide you a solution here.

Hello @JPCancino

I would like to give you some recommendations to support you

{%- for product in collection.products -%}
 {% if product.available == true %}   
  - {% render 'card-product',
        card_product: product,
        media_aspect_ratio: section.settings.image_ratio,
        show_secondary_image: section.settings.show_secondary_image,
        show_vendor: section.settings.show_vendor,
        show_rating: section.settings.show_rating,
        lazy_load: lazy_load,
        show_quick_add: section.settings.enable_quick_add,
        section_id: section.id
      %}
  

 {% endif %}
{%- endfor -%}

Hope my recommendation can works and support for you!

Kind & Best regards!

GemPages

Hi @KetanKumar , thanks for your time.

My site URL is https://cozy.cl

Best,

JP

Thank you for your help. It was easyer than I taugth.

In my case I use:

{% if product.available == true %}

Before the first

in product-grid-item.liquid (line 63) and close with:

{% endif %}

after

.

Many thanks.

Best,

JP

I am glad that my recommendation is helpful to you :grin: .