liquid - Shopify cart permalinks: check whether product is in-stock/sold out
I have a customised product.liquid template that includes two products in one template, namely: Bikini Top and Bikini Bottom.
The Bikini Bottom is "externally loaded" into the template using its own cart permalink. My question is, when using cart permalinks, how do I check whether the variant is in-stock or sold out and then display a "sold out" notice if needed?
[EDIT] Below is my cart permalink code for reference:
<form action="/cart/add" method="post" class="variantsform"> <label>Select size</label> <select name="id"> <option value="1189203320">Small</option> <option value="1189202416">Medium</option> <option value="1189200892">Large</option> <option value="1189203928">Extra Large</option> </select> <input type="hidden" name="return_to" value="back" /> <input type="submit" value="Add to cart" class="btn variantsadd"> </form>
at same that you load the variant with liquid, you have to check if is available. Variant manual reference (http://docs.shopify.com/themes/liquid-documentation/objects/variant#variant-available)
You also can use the product.first_available_variant (http://docs.shopify.com/themes/liquid-documentation/objects/product#product-first_available_variant)
Didn't find the answer?
Our community is visited by hundreds of Shopify development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.