To show the availability of a product to customers on your Shopify store, you can use the product.available
Liquid object. This object returns true
if the product is in stock and false
if it is out of stock.
Here is an example of how you could use the product.available
object in your Shopify theme to show or hide a message to customers based on the availability of a product:
{% if product.available %}
<p>This product is in stock and ready to ship!</p>
{% else %}
<p>Sorry, this product is currently out of stock.</p>
{% endif %}
You can also use the product.variants.first.available object to check the availability of a specific variant of a product. For example:
{% if product.variants.first.available %}
<p>This variant is in stock and ready to ship!</p>
{% else %}
<p>Sorry, this variant is currently out of stock.</p>
{% endif %}
I hope this helps! Let me know if you have any other questions.