Show a low stock alert when variant is selected - Dawn Theme

Topic summary

A user is attempting to display a low stock alert on their product page when a variant with fewer than 3 units is selected. They’ve implemented a Liquid code block that checks inventory quantity, but it’s behaving inconsistently.

Technical Issue:

  • The current Liquid code only evaluates on page load, not when users select different variants
  • Example: XS has 8 units, while 3XL and 4XL have 2 units each

Community Response:

  • Liquid is server-side and doesn’t respond to user interactions in real-time
  • Custom JavaScript is required to dynamically update the alert when variant selections change
  • One responder couldn’t locate the code on the referenced product page

Status: Unresolved. The user needs to implement a JavaScript solution or hire a developer to make the alert respond to variant selection events.

Summarized with AI on October 29. AI used: claude-sonnet-4-5-20250929.

I’m using a custom liquid block on my product form with the below code. I want this to reveal itself when someone selects a size with less than 3 units left. It should hide when they select a different size that’s got higher than 3 units left. It seems to work inconsistently. Any ideas?

Note the size XS has 8 units and the 3XL and 4XL have 2 units each.

https://katharinalou.com/products/the-annabel-maxi-peach-plaid

####           
{%- if product.selected_or_first_available_variant.inventory_quantity < 3 -%}
    Less than 3 left!
{%- endif -%}

Hi @pearlerwork

Liquid doesn’t update with user events, you need a custom javascript code to do so. You need to hire someone to do this for you

1 Like

Hi. Did you put the code in? I don’t seem to see it on the page.