Remove or Change the Out of Stock Text

In this post we will show you how you can change or remove the “Out of stock” text on the Woocommerce Single Product Pages with PHP.

 

This is how the text looks like before changing the code:

Remove or Change the Out of Stock Text

 

You can change the text by adding the following code to your functions.php file:

function arrow_design_modify_outOfStockText( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'This product is currently out of stock and unavailable.' :
//if you wish to insert text
$translated_text = __( 'This product is out of stock, but we are working on getting it back in stock soon!', 'woocommerce' );

break;
}
return $translated_text;
}

add_filter( 'gettext', 'arrow_design_modify_outOfStockText', 20, 3 );

This is how the text looks like after changing the code:

Remove or Change the Out of Stock Text

 

If you want to remove the text completely, use this code:

function arrow_design_modify_outOfStockText( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'This product is currently out of stock and unavailable.' :

//if you wish to remove
$translated_text = __( '', 'woocommerce' );

break;
}
return $translated_text;
}

add_filter( 'gettext', 'arrow_design_modify_outOfStockText', 20, 3 );

This is how the text looks like after using the second code snippet:

Remove or Change the Out of Stock Text

Conclusion

We hope this Remove or Change the Out of Stock Text post was helpful and you are now able to implement this on your own website! You can find more articles here:

 

Read another Woocommerce post : ‘Display ‘Change the Number of Products on Shop Page

 

Arrow Design, based in Dublin, Ireland, provides quality website design services in Dublin and beyond at affordable prices. If you would like help with implementing the above code, or any wordpress website development project, contact us. We love website design and it shows! We provide custom wordpress plugin development, website design training and lots more.

We do it all, so you don’t have to!

Related Posts

Woocommerce Account Page Hook Guide

In this article you will find a visual hook guide for the Woocommerce Account Pages, like the Login/Register page, the Downloads page or the Orders page.

Woocommerce PHP – Product Categories by Product ID

Woocommerce Single Product Page Hook Guide

In this article you will find a visual hook guide for the Woocommerce Single Product Page. This should help you to quickly and easily find the hook positions on the page.

Woocommerce PHP – Product Categories by Product ID

Woocommerce PHP – Product Categories by Product ID

In this tutorial you will learn how to check if a product is assigned to a tag, a category or a custom taxonomy. You can check if a product is is on the shop page, in the cart, in an order & more.

…We do more, so you can do less 🙂

 

Leave a message and we will be straight back to you!

Pin It on Pinterest

Share This