Ecommerce Shopify WordPress Discussion

Limit quantities of products ordered using code (no apps)

I'm trying to limit the quantity of a certain product per order. I want the customer to be able to buy no more than 2 of this product at once (plus other items if they want). I already found this code: I use Minimog 4.0 theme and I tried to configure it but it seems a bit old and does not work any more. If anyone can tell me what's wrong with this code, or provide another way to limit products quantities.
I think you should disable the plus button where the quantity of products is increasing in the cart drawer or page. For that, you have to add the max attribute up to max="2" to your input type. If it is related to cart quantity, then the below code will help you out, or else let me know if I misunderstood here. <quantity-input class="quantity cart-quantity"> <input class="quantity__input" type="number" name="updates[]" value="{{ item.quantity }}" {% # theme-check-disable %} data-cart-quantity="{{ cart | item_count_for_variant: }}" min="0" {% if item.variant.quantity_rule.max != null %}max="2"{% endif %} step="{{ item.variant.quantity_rule.increment }}" {% # theme-check-enable %} aria-label="{{ 'products.product.quantity.input_label' | t: product: item.product.title | escape }}" id="Quantity-{{ item.index | plus: 1 }}" data-index="{{ item.index | plus: 1 }}" > </quantity-input> Run code snippetExpand snippet

February 4, 2024

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.