How can I limit product quantity in the Impulse theme?

Topic summary

Limiting product quantity to available stock in the Impulse theme. Goal: set the quantity selector’s maximum to the selected variant’s inventory.

Initial approach: add an HTML max attribute bound to inventory in quantity-input.liquid for single-variant products. For multi-variant products, JS changes are required to enforce the limit.

Proposed JS edits in theme.min.js: read max from the input and clamp quantity changes. Early edits caused issues (images not loading, quantity stuck at 1); corrected code snippets were provided, but the limit still didn’t apply consistently.

Next steps offered: remote debugging and rewriting, noting the quantity function is used in multiple places. The store decided to handle the work in-house.

Alternative solutions: apps suggested to manage purchase limits globally (Purchase Limit, Limit Sales Per Day, Limit Quantity Purchase), including features for min/max per product and collections.

Latest update: a practical fix shared—insert max=“{{ product.selected_or_first_available_variant.inventory_quantity }}” in main-product.liquid around line ~284. A screenshot was provided and is central to implementation.

Status: partially resolved via Liquid for max setting; robust multi-variant JS enforcement may still require further development.

Summarized with AI on February 4. AI used: gpt-5.

Hey @SunShopp ,

I understand your query. I can suggest you one extension called Limit Quantity Purchase

The features of this app are as below:

  1. Specific Product purchase limits Minimum and Maximum.

  2. Flexible Purchase Limit of items within a group of products.

  3. Apply Limit For individual products or collection

It has all the features that you have mentioned in your query. Please, check it out here for more details: Shopify Limit Qty Purchase

Hope this helps you.

Thank you.