Remove quantity selector when only one item in stock

Topic summary

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.

Hi there,

I would like to remove the quantity selector box from my product pages when there is only one item in stock. I found this thread about the topic:

https://community.shopify.com/c/technical-q-a/remove-quantity-selector-if-stock-1/m-p/715971#M22975

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.

Thank you for your help!

Hi @roundthings

This is pretty simple if your product has no variants, add the following code right under the “when” statement:

{% if current_variant.inventory_quantity > 1 %}

Then add the following right after the last

{% endif %}

This will only display your quantity selector if the inventory is greater than 1.

Let us know if that works!

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?

Hi @roundthings - I came across this thread, and the reason the code above did not work, is because it should have been this:

{% if product.selected_or_first_available_variant.inventory_quantity > 1 %}

and not:

{% if current_variant.inventory_quantity > 1 %}

So your full code shoyuld have looked like this (I am also using the STUDIO Theme), and it worked for me correctly as follows:

{%- when 'quantity_selector' -%}
 {% if product.selected_or_first_available_variant.inventory_quantity > 1 %}             
            
              

              
            

{%- endif -%}

Hope that helps someone!

Can thank ChatGPT for that one!

Hi I’m looking for the same fix for the Spotlight theme and this isn’t working. Is there something different I could do?