There is an unfortunate (IMO) add to cart button naming on the WooCommerce shop page / category pages / product loops. When an item is out of stock, the “Add to cart” (or “Select options” for a variable product type) button label will turn into “Read more”.
To be honest, that doesn’t really say much to the end customer. It’s quite confusing and doesn’t make much sense.
Today, we’ll see how to change that “Read more” label into something more comprehensible: “Out of stock”. A super easy trick. Enjoy!
PHP Snippet: Rename “Read more” Button Label @ WooCommerce Shop / Category / Loop Pages
Note: take a look at the “Test” product in the screenshot above. That still shows “Read more”, so why’s that? Well, in that case the product is not out of stock, actually – it’s just not purchasable (I entered no regular price for it).
The snippet below will only act on the out of stock products. In case you wish to also include non purchasable items, you also need to run the ! $product->is_purchasable() check inside the function.
/**
* @snippet Read more > Out of stock @ WooCommerce Shop
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @testedwith WooCommerce 5
* @community https://businessbloomer.com/club/
*/
add_filter( 'woocommerce_product_add_to_cart_text', 'bbloomer_archive_custom_cart_button_text' );
function bbloomer_archive_custom_cart_button_text( $text ) {
global $product;
if ( $product && ! $product->is_in_stock() ) {
return 'Out of stock';
}
return $text;
}
WORKS LIKE A CHARM
THANK YOU, LOVE THE UPPERCASE!
This didn’t work for me unfortunately even after disabling all plugins and setting the theme to storefront, but I would really like this functionality so any help would be greatly appreciated!
I’m used the Elevated Lite theme using WordPress 6.6.1
Not sure, works perfectly in my test website
Still working. Thanks
Nice!
I added this code using the Code Snippets plug in but my sold out products still show “read more.”
Even if you temporarily disable all plugins but WooCommerce and switch theme?
Works using ‘Snippets’ plug in. THANK YOU!!!
Nice!
Worked perfectly on Hello theme plus Elementor and Woocommerce. Much appreciated. Easy and perfect fix!!
Thank you!
I searched and tried this code on several different platforms, but I couldn’t get it to work.
The code in this content worked without any problems. Thank you!
Great
Hi
For info
This sadly doesn’t work on Woodmart theme
Amy
Or maybe it is variable products that it doesn’t work on?
It should work for out of stock variable products as well