Help me hide the buy now button for sold items

https://ho6nudm7rx7entkl-71576191201.shopifypreview.com

please hide the buy now button from product page of all sold items on both mobile and pc .

1 Like

Hi @Shahil1

Please add this code to theme.liquid file, after in Sales channels > Online Store > Themes > click “…” next to theme you want to hide buttons > Edit code


just want to hide buy now button from individual product page, i want the soldout button to be there itself.

Please use this code


this fixed it . can you also give me acode to add to this custom liquid so that it gets hidden when the item is soldout
Screenshot 2025-03-12 095341.png

can you share your this custom liquide code

@Shahil1
here is a sample code for you

{% if product.available == false %}
    

This product is sold out.

{% else %}
    

This product is available for purchase.

{% endif %}

When product is sold out it will show the sold-out text when available it will show available. you can just use the condition above your custom liquide

Get it between -

{{ '//cdnjs.cloudflare.com/ajax/libs/datejs/1.0/date.min.js' | script_tag }}

Please use this condition {% if product.available == false %} above this code
and {% endif %} after this code block

Please update code to this