When creating a product page for my shop, it's easy to show {total_stock}. But how can I display the stock of a modifier, or disable a modifier based on it's stock?
For instance, when selling clothes, I want to only enable the size that are in stock.
The problem with this is that stock is linked to a SKU, and SKUs don't always map directly to a modifier. For example, if a "Shirt" product has both Size and Color, then you can't say definitively whether "Large" is out of stock, because it depends on the color as well.
That said, if your products only have a single modifier, then there is a 1-1 mapping. You should be able to access the stock level using {option_stock_level}
inside the {modifier_options}
loop, like so:
{modifiers}
<select name="{modifier_input_name}">
{modifier_options}
<option value="{option_id}">
{option_name} ({option_stock_level} remaining)
</option>
{/modifier_options}
</select>
{/modifiers}