Goal: hide the quantity selector on product pages when only one item is in stock (Shopify Online Store 2.0, Studio theme).
The initial approach using “current_variant.inventory_quantity > 1” did not work, even for products without variants.
Working fix for Studio: in Sections > main-product.liquid, within the “when ‘quantity_selector’” case, wrap the quantity markup with: “{% if product.selected_or_first_available_variant.inventory_quantity > 1 %} … {% endif %}”. This shows the selector only when inventory is greater than 1.
Note: a “variant” is a specific option combination; using “selected_or_first_available_variant” ensures a valid variant context even if none is explicitly selected.
Status and scope:
Confirmed working on the Studio theme by one participant.
A user on the Spotlight theme reports the fix does not work there; no alternative solution provided yet.
Key point: Code placement and the correct variant reference are essential; the code snippet is central to understanding and implementing the solution. Discussion remains open for Spotlight.
Summarized with AI on December 12.
AI used: gpt-5.
I tried to follow it but the code on my product file looks different. I found it under Sections>main-product.liquid. And the code for the quantity part looks like this:
{%- when 'quantity_selector' -%}
It’s different from the thread I linked above so I tried it and it didn’t work. How can I make this happen? I want the quantity box gone only when there is just one item in stock to make the navigation make more sense. I am using the Studio theme, it’s a 2.0 store if that helps resolve this.
Hi there, thank you for replying! None of my products have variants at the moment. But I just tried adding these two lines where you instructed and it didn’t work unfortunately. The quantity box still shows on the product pages of all products (including the ones that only have one item in stock). Any other suggestions?