Disable the Minus Button at Quantity 1 in WooCommerce

Quick Summary
- A jQuery snippet disables the quantity minus button while the value is 1 and enables it again once the number goes up.
- The check runs on page load and after every click in the quantity box, and expects minus, qty and quantity classes from your theme.
- It works best on a single product page, since on the cart the first row's quantity decides for every minus button.
Many themes add plus and minus buttons around the WooCommerce quantity field, but the minus button stays clickable when the quantity is already 1. This jQuery snippet disables the minus button while the quantity is 1 and enables it again as soon as the number goes up.
WooCommerce itself doesn’t add these buttons; they come from your theme or a plugin. The code expects the button to have the class minus and the input the class qty, both inside a .quantity wrapper, so check your theme’s markup and adjust the selectors if they differ. Add it to your theme’s JavaScript file. WordPress loads jQuery in no-conflict mode, so wrap the code in a jQuery ready handler that passes in $; the $ is not a function error explains why.
if ($('.qty').val() == 1) {
$(".minus").attr("disabled", true);
}
$('.quantity').on('click', function() {
if ($('.qty').val() == 1) {
$(".minus").attr("disabled", true);
} else {
$(".minus").attr("disabled", false);
}
});How it works
- When the page loads, the first
ifchecks the value of.qty. If it is 1, the.minusbutton gets thedisabledattribute. - Every click inside the
.quantitybox, including clicks on the plus button, runs the same check again and disables or enables the minus button. .attr("disabled", false)removes the attribute, so the button works again.
Limits
- The code reads the first
.qtyfield on the page and toggles every.minusbutton. That suits a single product page with one quantity field; on the cart page with several rows, the first row decides for all of them. - It only reacts to clicks. Typing a number into the field doesn’t update the button until the next click inside the box.
If your product page’s quantity input needs more custom behavior, that’s part of my WooCommerce development work.
Related articles
- making the plus and minus buttons respond: the handlers that change the quantity in the first place
- keeping the buttons working after a cart update: rebinding them when WooCommerce reloads the cart
