Skip to content
ThemesIonic — home
WooCommerce

"You Cannot Add That Amount to the Cart": How WooCommerce Counts Stock

Two different stock checks produce the message: one for the quantity being added, one for that quantity plus what the cart already holds. Variations sharing the parent's stock and stock reserved by unpaid orders explain most of the surprising cases.

5 min read intermediate

WooCommerce shows "You cannot add that amount to the cart" when the quantity being added, alone or together with what is already in the cart, is more than the product's stock. The check only runs for products with Manage stock enabled and backorders not allowed, and it reads the stock quantity stored on the product at that moment. Either the store really has too few units, or WooCommerce is counting differently from the person looking at the product page. The second case causes most of the confused reports.

Two checks, two messages

WC_Cart::add_to_cart() runs the stock checks in a fixed order, and each one has its own wording:

Message Check
You cannot add "Product" to the cart because the product is out of stock. The product is not in stock at all
You cannot add that amount of "Product" to the cart because there is not enough stock (N remaining). The quantity being added is more than the stock
You cannot add that amount to the cart — we have N in stock and you already have M in your cart. The quantity being added plus the quantity in the cart is more than the stock
You cannot add another "Product" to your cart. The product is Sold individually and is already in the cart

The third line is the one people search for. It is easy to trigger: a shopper adds 3 of a product with 5 in stock, comes back later and adds 3 more. The cart holds 3, 3 + 3 is more than 5, and the second add is refused. The shopper now has 3 and assumes the shop is broken. If the cart page exists, WooCommerce adds a View cart button so they can change the quantity there instead.

The trap: variations that share the parent's stock

A variation can manage its own stock, or leave stock to the parent product. That is the Manage stock? setting at product level, with the variation's own box unticked. In the second case the cart check does not count per variation. WooCommerce groups cart items by get_stock_managed_by_id(), which for those variations is the parent's ID. Then it compares the combined quantity with the parent's stock.

So with 4 T-shirts in stock across all sizes:

  1. The shopper adds 2 × Medium. Fine, 2 ≤ 4.
  2. They add 3 × Large. Refused: "we have 4 in stock and you already have 2 in your cart."

The message is correct, but the shopper sees "you already have 2" and knows they have no Large in the cart. If each size really has its own stock, move the stock to the variations: tick Manage stock? on each variation and enter its own quantity. The trade-offs between the two models are covered in inventory management.

The other trap: stock reserved by unpaid orders

The block-based cart and checkout add through the Store API, which runs its own check. Before it compares quantities, it subtracts reserved stock: units held for orders that were placed at checkout but not yet paid, within the Hold stock (minutes) window under WooCommerce › Settings › Products › Inventory.

That makes this sequence possible:

  • The product page says "5 in stock". It reads the stored stock quantity.
  • Two other shoppers are sitting on the payment page with 2 units each.
  • The block cart refuses an add of 2: "You cannot add that amount of Product to the cart because there is not enough stock (1 remaining)."

Nothing is wrong. The number in the message is the unreserved remainder, not the stock you entered. The classic add to cart check does not subtract reservations. With the classic cart, the same shortfall shows up at checkout instead, as: Sorry, we do not have enough "Product" in stock to fulfill your order (N available). Shortening the hold time frees reserved units sooner. Only orders still in pending or checkout draft hold stock, so a failed payment releases its units at once; an abandoned one holds them until the hold expires.

Cause list, in order of likelihood

  1. Real low stock. Check the product's stock under Inventory. If it shows a number you did not expect, the CSV import or a stock sync tool may have overwritten it.
  2. Quantity already in the cart, including quantities restored from a previous session.
  3. Parent-level stock for variations, as above.
  4. Reserved stock on the block cart.
  5. Quantity rules. Plugins that force a minimum or step, such as packs of 6, can change the quantity through woocommerce_add_to_cart_quantity before the stock check. A pack rule on a product with 4 in stock can never pass.

What not to do

Do not remove the check with code. The stock checks run inside add_to_cart() after validation filters such as woocommerce_add_to_cart_validation, and they protect you from overselling. If a product should be orderable beyond stock, allow backorders on that product. If the limit is right but the message confuses shoppers, change the text with the two filters:

add_filter( 'woocommerce_cart_product_not_enough_stock_already_in_cart_message',
	function ( $message, $product, $stock_quantity, $in_cart ) {
		return sprintf(
			'Only %1$s left of %2$s, and %3$s are already in your cart.',
			wc_format_stock_quantity_for_display( $stock_quantity, $product ),
			$product->get_name(),
			wc_format_stock_quantity_for_display( $in_cart, $product )
		);
	}, 10, 4 );

The filtered message replaces the whole string, including the View cart button. Add a cart link back if you want to keep it.

Common mistakes

  • Showing stock in the catalogue but managing it on the parent. "3 in stock" on a size the shopper picks may describe all sizes together.
  • Testing with an admin account and a stale cart. Your own earlier test items count. Empty the cart first.
  • Raising stock to make the message go away. The next order then ships stock you do not have.
  • Blaming a cache. WooCommerce sends no-cache headers with add to cart requests, and the check reads the stock from the database. A cached product page can show an old stock number, but it cannot cause the refusal.

Verify

  1. Empty the cart and add the full stock quantity of a test product. It should succeed.
  2. Add one more unit. You should get the "already have" version.
  3. For a variable product with parent-level stock, add two different variations and confirm they count together.
  4. On a block cart, place an unpaid order for one unit in another browser and confirm the "remaining" number drops by one until the hold time ends.

Frequently asked

The variation's stock is managed at the product level. WooCommerce then adds up every variation of that product in the cart and checks the total against the parent's stock, so two Mediums count against the Large you are adding.
Yes. Both checks pass whenever stock management is off or backorders are allowed for that product or variation. Allow backorders only if you can really fulfil late. Otherwise you swap an add to cart notice for orders you cannot ship.
Yes. woocommerce_cart_product_not_enough_stock_message filters the first version and woocommerce_cart_product_not_enough_stock_already_in_cart_message the second. Both receive the product and the stock quantity. Changing the text does not change the check.

Related guides