Rename “Read more” To “Out of stock” in Woocommerce

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”.

Today, we learn how to change that “Read more” label into something more comprehensible: “Out of stock”.

Rename “Read more” Button Label  in WooCommerce Shop / Category / Loop Pages

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.

add_filter( 'woocommerce_product_add_to_cart_text', 'archive_custom_cart_button_text' );
  
function archive_custom_cart_button_text( $text ) {
   global $product;       
   if ( $product && ! $product->is_in_stock() ) {           
      return 'Out of stock';
   } 
   return $text;
}