When a customer tries to add too many of an item to cart, they see this error notice:
You cannot add that amount to the cart - we have X in stock and you already have Y in your cart.
This behavior is included on WC_Cart
add_to_cart()
method source code at line 1067
.
I will like to hide stock details and replace it with:
You cannot add that amount to the cart — we don't have enough in stock.
How to change this add to cart stock error notice in WooCommerce, without overwriting source code?
You can change the said text without modifying the plugin files with the help of "Say What" Plugin. Follow the following steps to change the text:
Install Say What plugin
Visit Tools > Text Changes
Click Add New
Fill the fields as per your need e.g.
You cannot add that amount to the cart — we have %1$s in stock and you already have %2$s in your cart.
woocommerce
You cannot add that amount to the cart — we don't have enough in stock.