Limited number of quantity in xclusive the

Topic summary

Goal: Cap the purchasable quantity per product variant at 3, without limiting total items in the cart, and avoid using an app.

Current state: The cart templates (slide-cart.liquid and main-cart.liquid) already restrict quantity via dropdown max values. The remaining need is to limit quantity on the product page (main-product.liquid) so users can’t exceed 3 by clicking “Add to Cart.”

Proposed solution: Set a hard cap on the quantity input in the product form using the HTML number input’s max attribute.

  • Simple approach: Add max=“3” to the quantity input field if the theme uses a qty input.
  • Inventory-aware approach: Set max to the lesser of current_variant.inventory_quantity and 3 (i.e., if inventory ≤ 3 use that value; otherwise use 3). This preserves accurate stock limits while enforcing the per-variant cap.

Key implementation detail: The max attribute on an input type=number limits the highest selectable quantity on the product page.

Status: Guidance provided; awaiting confirmation from the requester after implementing the conditional max logic.

Summarized with AI on December 22. AI used: gpt-5.

Hi team,

I aim to restrict the quantity of each product variant to a maximum quantity (i.e. 3), while ensuring that there are no limitations on the items added to the cart.

I have successfully modified the code within ‘slide-cart.liquid’ and ‘main-cart.liquid’ to enforce a constraint on customers by setting a maximum value in the dropdown menu. Presently, I seek guidance on further restraining the number of clicks on the ‘Add to Cart’ button within ‘main-product.liquid’.

Could you kindly provide instructions on implementing this additional limitation? (P.S. I don’t want to install APP if possible)

Many Thanks,

Hi @Jlaw2024 if your theme uses qty input field - you can do it there by adding max=“3” parameter to input field.

Hi @Ihor-Sh

thanks for your reply.

are you referring to change max in below code under {%- form product %}?

{%- form ‘product’, product, id: form_id, class: form_class, autocomplete: “off” -%}
{%- if gift_card_recipient_feature_active -%}
{%- render ‘gift-card-recipient-form’, product: product, form: form, section: section -%}
{%- endif -%}

{%- if block.settings.show_amount_selection -%} {{ 'product.form.quantity' | t }} {%- endif -%}

Hi team, any update?

instead of {{current_variant.inventory_quantity }}
set {%- if current_variant.inventory_quantity <= 3 -%} {{current_variant.inventory_quantity }} {%- else -%}3{%- endif -%}