Re: Limited number of quantity in xclusive the

Limited number of quantity in xclusive the

Jlaw2024
Visitor
3 0 0

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,

Replies 4 (4)

Ihor-Sh
Shopify Partner
79 11 17

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

Shopify troubleshootibility 😉
If you're satisfied with reply - don't forget to like it.
If you more than satisfied - mark it as solution 😉
You can find me here.
Jlaw2024
Visitor
3 0 0

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 -%}
<p class="submit m10 {% unless current_variant.available %}unavailable{% endunless %}" {{ block.shopify_attributes }}>
{%- if block.settings.show_amount_selection -%}
<span class="input-amount">
<label for="quantity" class="hidden">{{ 'product.form.quantity' | t }}</label>
<input type="number" id="quantity" name="quantity" data-link="#product_qty_sticky" value="{{ current_variant.quantity_rule.min }}"
min="{{ current_variant.quantity_rule.min }}"
{% if current_variant.inventory_management == 'shopify' and current_variant.inventory_policy == 'deny' -%}
max="{{ current_variant.inventory_quantity }}"
{% elsif current_variant.quantity_rule.max %}
max="{{ current_variant.quantity_rule.max }}"
{% endif %}
{% if current_variant.quantity_rule.increment %}step="{{ current_variant.quantity_rule.increment }}"{% endif %}
required>
</span>
{%- endif -%}

Jlaw2024
Visitor
3 0 0

Hi team, any update?

Ihor-Sh
Shopify Partner
79 11 17

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

Shopify troubleshootibility 😉
If you're satisfied with reply - don't forget to like it.
If you more than satisfied - mark it as solution 😉
You can find me here.