If a customer tries to add more of a product than the current WooCommerce stock level, they will see a “tooltip” letting them know they need to use a smaller quantity. This message is generated by the browser and typically isn’t very attractive. Here’s what it looks like in Chrome.
This is generated by the HTML that makes up the quantity input. It’s a “number” input and the specifications allow us to assign minimum and maximum values to the field. We can see that WooCommerce uses the stock levels to add these to the HTML.
There is a way to disable this with a filter. Add this snippet to your theme’s functions.php file or with a plugin like Code Snippets and that should turn this off for you.
add_filter( 'woocommerce_quantity_input_max', '__return_false' );
In case you were wondering, doing this doesn’t remove all validation from the quantity. If a customer tries to add more of the product than we have in stock, they’ll still see an error message.
So if you don’t find this message particularly helpful, you can use that filter to remove it from your store. If you have any questions, post them in the comments below.
Leave a Reply