There are various ways to handle stock within WooCommerce. When your products are out of stock and you do not allow backorders for the product, WooCommerce will show a ‘Out of stock’ type of message. Here’s an example with the Storefront theme.
If you sell custom, unique or otherwise limited stock you may want to change the ‘Out of stock’ message to be more descriptive. When a product says ‘Out of stock’ it may indicate to customers it may return in stock over time, while for those unique or custom items this will not be the case.
For those kinds of products a ‘Sold’ or ‘Sold out’ message will more clearly communicate to customers that it will not return back in stock. To change the default ‘Out of stock’ messaging a small code snippet is required.
Within the code snippet you are able to change the text to whatever you’d like it to be. The result is as shown below;
Is there a way to also change the “In Stock” message with this code? When I try to do it using other code I find, it messes up this code. I want it to read “In Stock” vs. “In Stock (Can Be Backordered)”
Hi,
Sure, you can change the first bit to change the text when in stock instead of when its out of stock;
if ( $product->is_in_stock() ) {
– removing the exclamation mark.Cheers,
Jeroen