Hide add to cart button when variant inventory is 0 and display correct inventory quantity

Hi All,

This is driving me nuts as all of the examples I have found when googling this seem to relate to newer templates and reference files e.g. theme.js that I do not have. I’m using template ‘New Standard’.

Currently customers are able to add variants that have inventory of 0 to their cart (and cannot se it is out of stock) which obviously causes issues and has meant me removing out of tock variants completely which is obviously not practical.

I understand that I need find and update the setCallback function which for me is at the bottom of product.liquid:

But can’t work out what to change based on examples people have posted which also talk about changing .js files I don’t seem to have.

I have been able to add code to product.liquid to show the quantity in stock (but only of the default variant):

{% if product.variants.first.inventory_management == “shopify” %}
{% if product.variants.first.inventory_quantity > 0 %}
There are currently {{ product.variants.first.inventory_quantity }} in stock.
{% else %}
This product is out of stock.
{% endif %}
{% else %}
This product is available
{% endif %}

Any pointers would be very much appreciated :slightly_smiling_face:

Regards

Ian.