How can I limit product order quantity to one in Dawn Theme?

Hello everyone, I know many asked this question before but i’m still struggeling with that. I want to limit order quabtity to 1 for a specific product. I know I have to edit my code at this section:

{{ 'products.product.quantity.label' | t }} {{ 'products.product.quantity.decrease' | t: product: product.title | escape }} {% render 'icon-minus' %}

<input class=“quantity__input”
type=“number”
name=“quantity”
id=“Quantity-{{ section.id }}”
min=“1”
value=“1”
form=“{{ product_form_id }}”

{{ 'products.product.quantity.increase' | t: product: product.title | escape }} {% render 'icon-plus' %}

I know I have to put an if/else snippet here, but I don’t really know how. I tried a few things but everytime an Error pops up like: Liquid syntax error: Unknown tag ‘when’

I’m using the Dawn Theme

1 Like
{% assign limited_product_handle = 'product-handle-string' %}

{% if product.handle == limited_product_handle %}
    
{% else %}
    

The alternative is to use alternate templates for those specific product where the custom component <quantity-input class="quantity"> is completely replaced with a basic hidden input.

Or course the deeper problem here is these triput button components are never made to obey the max attributes values on the input itself so the minus/plus will ignore a max="1" declaration.

@PaulNewton sorry that didn’t work for me, when I just put a max attribute to the original code, that works but I can’t point to a specific Item. When i create a new template how can I use this then?

{% assign productTags = product.tags %} 

         {% if productTags contains "noquantity" %}
          {% else %}  
               

 @PaulNewton ok that works for me thank you for showing me the right direction.
1 Like

Alternate templates are applied per resources in that resources admin , outside of the theme editor.

For products and pages this is a selector on the right sidebar when the live theme has an alternate template for that resource type

https://help.shopify.com/en/manual/online-store/themes/theme-structure/templates#:~:text=the%20selected%20template.-,Apply%20a%20new%20template,-You%20can%20change

If either helped mark the solutions for future merchants, thanks

Hi @_Tom , wondering how to restrict specific products or pages on Shopify? Watch this informative video tutorial:

Did this solution work for you? I have the same situation, I also need to limit a product quantity per order. I need no more than 5 items per order of one product due to specifics of shipping. I do not code at all so I have no idea where to insert this code…