In this post, we’ll be discussing how to customize the maximum quantity per product that can be added to a cart in WooCommerce using a simple code snippet. With this code snippet, you can set it to 1000 or any other number that you prefer.
When it comes to selling products online, one of the most important features is the ability to control the quantity of items that can be added to a cart. This is especially important for large, wholesale orders or for items that have a limited stock.
The code snippet we’ll be discussing today uses the woocommerce_quantity_input_max filter
to set it to 1000. The add_filter
function is used to attach the custom_woocommerce_quantity_input_max
function to the woocommerce_quantity_input_max
filter. The function then takes two parameters, $max
and $product
, and sets the maximum quantity to 1000.
It’s worth noting that you can replace the number 1000 with any number you want, so you can have a different max quantity for different products or categories.
By adding this code snippet to your functions.php file, you can easily set maximum quantity per product that can be added to a cart in WooCommerce. This can come in handy for wholesale orders or for items that have a limited stock. Remember to test it before going live and make sure you have the proper backup of your website.