Changing "out of stock" label

Hello!

Is there a way to change the text “Out of Stock” to “Sold out”?

Screen Shot 2020-11-17 at 3.59.14 PM

My site is crisisequipped.com
Thanks so much for your help!

Nadia

Hi Nadia,

Thanks for reaching out.

Please check this doc on how to change a single text on your website. Single Sentence Translation

Hope that helps.

Thank you.

Hi Marc,

Thank you for your prompt reply. I looked at the document you linked but I still don’t understand how to do it…
I want all the “Out of Stock” labels across my website to be changed to “Sold out” on Woocommerce.

Thanks for your help.

Hi Nadia,

In your child theme add this code in functions.php

function custom_text_translate($translated) {
  $translated = str_ireplace('Out of Stock', 'Sold out', $translated); return $translated;
}
add_filter('gettext', 'custom_text_translate' );

Hope that helps and let us know how it goes.

Thank you.

Hello!

It didn’t work :frowning:

Any other ideas?

Hi Nadia,

Replace the previous code with this code in the child theme’s functions.php file.

add_filter( 'woocommerce_get_availability' , 'wcs_custom_get_availability' , 1, 2);
function wcs_custom_get_availability( $availability , $_product ) {
     if ( ! $_product ->is_in_stock() ) {
         $availability [ 'availability' ] = __( 'Sold Out' , 'woocommerce' );
     }
     return $availability ;
}

Please note that the code provided above serves as a guide only and is to help you in getting started so implementing it and maintaining the code will be out of our support scope and for further maintenance for new possible versions of the theme that may cause the customization to break, you will need to hire a developer.

Hope it helps you.
Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.