Change read more text to out-of-stock on the shop in WooCommerce

Change read more text to out-of-stock on the shop in WooCommerce on child sites.

Snippet Type

Execute on Child Sites

Snippet

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