Title: Quantity field problem
Last modified: April 11, 2022

---

# Quantity field problem

 *  Resolved [joelmellin](https://wordpress.org/support/users/joelmellin/)
 * (@joelmellin)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/quantity-field-problem/)
 * Hi!
 * I have a problem with the quantity people can add to the cart. Earlier it was
   only possible to add a quantity that was equal to the maximum stock. But now 
   they can add an unlimited number to the cart (even if nothing of it shows up 
   in the cart). I want the number to stop at our maximum stock.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fquantity-field-problem%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Margaret S. woo-hc](https://wordpress.org/support/users/margaretwporg/)
 * (@margaretwporg)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/quantity-field-problem/#post-15547036)
 * Hi [@joelmellin](https://wordpress.org/support/users/joelmellin/)
 * I tried and was able to load 15 quantities of a product to cart, but when I checked
   the cart it was empty. It seems that items not getting added to cart needs to
   be addressed before stopping adding quantity depending on stock.
 * Here’s an article that may help: [https://www.boiseweb.net/articles/why-a-woocommerce-product-wont-add-to-the-cart-with-fixes/](https://www.boiseweb.net/articles/why-a-woocommerce-product-wont-add-to-the-cart-with-fixes/)
 * As for setting the maximum limit per product so that it doesn’t exceed the stock
   availability, you can use the [Min and Max Quantity for WooCommerce](https://wordpress.org/plugins/minmax-quantity-for-woocommerce/)
   plugin. You can read more on it here: [https://storepro.io/learn/how-to-set-minimum-and-maximum-order-quantity-in-woocommerce/#set-min-and-max-quantity-with-min-and-max-quantity-for-woocommerce-plugin-free](https://storepro.io/learn/how-to-set-minimum-and-maximum-order-quantity-in-woocommerce/#set-min-and-max-quantity-with-min-and-max-quantity-for-woocommerce-plugin-free)
 * For any queries you may have about the plugin, feel free to open a topic here:
   [https://wordpress.org/support/plugin/minmax-quantity-for-woocommerce/](https://wordpress.org/support/plugin/minmax-quantity-for-woocommerce/)
 * I hope this helps!
 *  Thread Starter [joelmellin](https://wordpress.org/support/users/joelmellin/)
 * (@joelmellin)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/quantity-field-problem/#post-15548257)
 * Hi!
 * The problem is not that the cart was empty when you tried to add 15 units, because
   it should not be possible if the stock is less than 15. The problem I have is
   that you could try to add 15 units. I want the number to automatically stop at
   maximum stock so that it is not even possbible to _try_ to add more than there
   is in stock.
 * This has worked before, but now it doesn’t. The plugin you gave a link for does
   not fix that problem, I tried it but there is no option for that.
    -  This reply was modified 3 years, 11 months ago by [joelmellin](https://wordpress.org/support/users/joelmellin/).
    -  This reply was modified 3 years, 11 months ago by [joelmellin](https://wordpress.org/support/users/joelmellin/).
 *  [Mirko P.](https://wordpress.org/support/users/rainfallnixfig/)
 * (@rainfallnixfig)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/quantity-field-problem/#post-15549525)
 * Hi [@joelmellin](https://wordpress.org/support/users/joelmellin/),
 * Thank you for providing more details. Do you allow backorders?
 * 
    Link to image: [https://i.imgur.com/Sy3YfyZ.png](https://i.imgur.com/Sy3YfyZ.png)
 * If you allow them, your customers can enter any number in the quantity box and
   it will be accepted. Instead, if you do not allow backorders, and your customer
   tries to enter a quantity over the allowed stock they should get a warning:
 * 
    Link to image: [https://i.imgur.com/Af8uMkm.png](https://i.imgur.com/Af8uMkm.png)
 * Let us know if this helps.
 *  Thread Starter [joelmellin](https://wordpress.org/support/users/joelmellin/)
 * (@joelmellin)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/quantity-field-problem/#post-15557951)
 * No we do not allow back orders.
 * Earlier the counter (that is marked with a red triangle in the attached picture)
   would automatically stop at the maximum stock when pushing the + button. But 
   now it doesn’t.
    [Picture](https://mellins.nu/wp-content/uploads/2022/04/Namnl%C3%B6s.png?_t=1649926101)
 * It seems like this part of the code is not working anymore:
 * function woa_woocommerce_quantity_input_args( $args, $product ) {
    if ( is_singular(‘
   product’ ) && $product->is_type( ‘simple’ ) && $product->is_purchasable() && 
   $product->is_in_stock() && ! $product->is_sold_individually() ) { $args[‘input_value’]
   = 1; // Starting value (we only want to affect product pages, not cart) } $args[‘
   max_value’] = $product->get_stock_quantity; // Maximum value $args[‘min_value’]
   = 0; // Minimum value $args[‘step’] = 1; // Quantity steps return $args; }
    -  This reply was modified 3 years, 11 months ago by [joelmellin](https://wordpress.org/support/users/joelmellin/).
 *  [Igor H](https://wordpress.org/support/users/ihereira/)
 * (@ihereira)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/quantity-field-problem/#post-15558213)
 * Hello,
 * I recommend debugging the code to check it will work according to your needs.
   That way you can make sure the condition on the code is working as expected or
   if it needs some adjustment.
 * To learn more about debugging please refer to:
 * * [https://woocommerce.com/document/woocommerce-product-search/api/debugging/](https://woocommerce.com/document/woocommerce-product-search/api/debugging/)
 * * [https://developer.woocommerce.com/testing-extensions-and-maintaining-quality-code/debugging-tools/](https://developer.woocommerce.com/testing-extensions-and-maintaining-quality-code/debugging-tools/)
 * I hope this helps.
 *  [Margaret S. woo-hc](https://wordpress.org/support/users/margaretwporg/)
 * (@margaretwporg)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/quantity-field-problem/#post-15577029)
 * We haven’t heard back from you in a while, so I’m marking this thread as resolved–
   we’ll be here if and/or when you are ready to continue.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Quantity field problem’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [quantity field](https://wordpress.org/support/topic-tag/quantity-field/)

 * 6 replies
 * 4 participants
 * Last reply from: [Margaret S. woo-hc](https://wordpress.org/support/users/margaretwporg/)
 * Last activity: [3 years, 11 months ago](https://wordpress.org/support/topic/quantity-field-problem/#post-15577029)
 * Status: resolved