Show text when specific size reaches 0 quantity

Topic summary

Goal: Show a preorder message on the product page when a specific size variant’s stock hits 0, while still allowing purchases.

Context: Store uses the Dawn theme; inventory tracking and selling when out of stock are desired to enable preorders.

Proposed approach (non-dynamic): Add a Custom Liquid block on the product page that checks inventory_quantity of the first and last variants (assumes exactly two sizes in a fixed order) and displays a static message indicating which size(s) are out of stock. Requires inventory tracking and “sell when out of stock” enabled. A Liquid code snippet was provided; a screenshot illustrates adding the block.

Limitations:

  • Breaks if there are more than two variants or more than two sizes.
  • Not dynamic per selected variant; message does not update when a different variant is chosen.
  • Products with a single variant may need a separate template.

Status: OP appreciates the workaround but was aiming for a dynamic, per-selection message. No dynamic solution provided yet; discussion remains open without a finalized approach.

Summarized with AI on January 19. AI used: gpt-5.

This is a complex question and implementing this functionality requires very deep knowledge. I have came up with a hackish solution, that works in similar way, but has many limitations and should only be used if nobody comes up with a better idea.

If you have two sizes for all products and they’re in exact order as you’ve described, you can display a static message. It will be one of these messages, based on product variant quantities left:

XL size is out of stock but available for preorder

XL to 3XL size is out of stock but available for preorder

XL and XL to 3XL sizes are out of stock but available for preorder

To add this functionality you must have inventory tracking and selling when out of stock for your products enabled.

Go to Online Store → Themes → Customise
Select your product page template and add liquid block in Product information. Copy and paste following code:

{% if product.variants.first.inventory_quantity == 0 and product.variants.last.inventory_quantity > 0 %}

XL size is out of stock but available for preorder

{% elsif product.variants.first.inventory_quantity > 0 and product.variants.last.inventory_quantity == 0 %}

XL to 3XL size is out of stock but available for preorder

{% elsif product.variants.first.inventory_quantity == 0 and product.variants.last.inventory_quantity == 0 %}

XL and XL to 3XL sizes are out of stock but available for preorder

    {% endif %}

Limitations:

  • functionality breaks if there are more than 2 variants.
  • functionality breaks if there are more than 2 sizes in the store.
  • if there are products with just 1 variant you might need to create and adjust different product template for them.
  • message is static and does not change dynamically depending on chosen variant.

Due to the limitations I strongly advise using this method only if you can’t find a better solution.