Smart Cart offers built-in settings to control product quantities globally, as well as code-based workarounds for more specific use cases. Which approach you use depends on whether you need limits to apply to all products or only certain ones.
Scenario | Recommended approach |
Set a min/max quantity limit on all cart items | Enable Quantity Input (native setting) |
Hide quantity controls entirely on specific products |
|
Set different quantity limits per product | Custom code in Smart Cart Advanced > Ready |
Option 1: Enable Quantity Input (Native Setting)
Smart Cart's Enable Quantity Input setting lets you set a minimum and maximum quantity for all products in the cart, and control how customers adjust quantity. This is the recommended approach when a single quantity limit applies to all of your products.
To configure it, navigate to your Smart Cart editor, open Cart Items Settings, and toggle on Enable Quantity Input. You can then set:
Minimum Quantity Value — The lowest quantity a customer can set for any product.
Maximum Quantity Value — The highest quantity a customer can set for any product.
Quantity Input Type:
Buttons/Manual Input — Standard −/+ buttons, with the ability to type a quantity directly.
Dropdown Select — A dropdown menu showing available quantity options.
You can also customize Error Messages shown when a customer enters a quantity outside the allowed range. Use {{min}} and {{max}} as placeholders to dynamically insert your configured limits.
Note: This setting applies to all line items globally. If you need different limits for specific products, use the custom code approach in Option 3 below.
Option 2: Hide Quantity Buttons on Specific Products
If your theme already restricts how many of a product a customer can add (for example, a product limited to one per order), you may simply need to hide the quantity controls in Smart Cart so customers can't bypass that limit inside the cart.
Tag the product in Shopify with smart-cart-hide-qty. This tag automatically hides the quantity buttons on that product's line item in Smart Cart.
Option 3: Set a Maximum Quantity via Custom Code
If you need per-product quantity limits — or a limit that differs between products — you can add custom JavaScript to the Smart Cart > Advanced > Ready section.
The code below is pre-built — you only need to make minor adjustments. We recommend testing in a duplicate Smart Cart using preview mode before going live.
Limit quantity on all products
Add the following code to Smart Cart > Advanced > Ready. Change the 5 in both places to your desired maximum — both numbers must match.
/* limit quantity for ALL products in Smart Cart */
function limitItemQuantities() {
setTimeout(() => {
/* pull in all the cart items */
const cartItems = Rebuy.SmartCart.items();
/* check quantity and lower if needed */
cartItems.forEach(item => {
if (item.quantity > 5) { /* <-- this is the max quantity a user can add */
/* lower item quantity back to the maximum */
Rebuy.Cart.setItemQuantity(item, 5) /* <-- this is the max quantity a user can add */
}
})
}, 400);
}
document.addEventListener('rebuy:cart.change', limitItemQuantities)
Limit quantity on specific tagged products
To apply limits only to certain products, tag those products in Shopify, then reference that same tag in the code below. Add the code to Smart Cart > Advanced > Ready.
/* limit quantity for tagged products in Smart Cart */
function limitItemQuantities() {
setTimeout(() => {
/* pull in all the cart items */
const cartItems = Rebuy.SmartCart.items();
/* check for product tag and quantity, lower quantity if needed */
cartItems.forEach(item => {
if (item.product?.tags.includes("Place tag here") && item.quantity > 5) { /* <-- this is the max quantity for tagged products */
/* lower item quantity back to the maximum */
Rebuy.Cart.setItemQuantity(item, 5) /* <-- this is the max quantity for tagged products */
}
})
}, 300);
}
document.addEventListener('rebuy:cart.change', limitItemQuantities)
Replace "Place tag here" with the Shopify tag on your restricted products, and change 5 in both places to your desired maximum. How Shopify tags work.
Example: If your products are tagged max5, the condition line should read:
if (item.product?.tags.includes("max5") && item.quantity > 5) {
Where to Find Smart Cart > Advanced > Ready
To Paste this code:
Open to your Smart Carts Admin & select your cart.
Click on Global SETTINGS (Gear Icon).
Navigate to the Advanced tab.
Scroll to the EVENT CALLBACKS.
Paste code in READY Callback Box.
Notifying Customers of Quantity Restrictions
Once quantity limits are in place, consider how you'll communicate them to customers:
Product page: If your theme restricts quantities at the product level, it should already display this to customers on the product page.
Announcement Bar: Use the Smart Cart Announcement Bar to display a quantity limit message inside the cart.
Line item properties: If your products carry line item properties, Smart Cart displays them automatically on the line item. Consult Shopify Support or your theme developer for help configuring this.
Custom Code block: Use the Custom Code section in Smart Cart settings to add a visible text element. CSS can be applied for styling.
Custom template: Use a Smart Cart custom template to add messaging anywhere in the cart.



