Changing Woocommerce 'Out of Stock' text

mrvargo
10 Posts
mrvargo posted this 1 weeks ago

Hi. I'm trying to change the out of stock notice which appears on the thumbnail in Woocommerce product category display. I've inserted the following code (and a few variations) into functions-additional.php but it has no effect. Does anyone have a solution for this? Thanks

add_filter('woocommerce_get_availability', 'availability_filter_func');
function availability_filter_func($availability)
{
$availability['availability'] = str_ireplace('Out of stock', 'Sold', $availability['availability']);
return $availability;
}

Hi. I'm trying to change the out of stock notice which appears on the thumbnail in Woocommerce product category display. I've inserted the following code (and a few variations) into **functions-additional.php** but it has no effect. Does anyone have a solution for this? Thanks add_filter('woocommerce_get_availability', 'availability_filter_func'); function availability_filter_func($availability) { $availability['availability'] = str_ireplace('Out of stock', 'Sold', $availability['availability']); return $availability; }
Vote to pay developers attention to this features or issue.
3 Comments
Order By: Standard | Newest
Support Team
Support Team posted this 1 weeks ago

Hi,

Do you mean that you vant to change the text of the Out of Stock control? In this case please try adding the following code to the Themler Settings >> CMS Code:

add_filter( 'gettext', 'wps_translate_words_array' );
add_filter( 'ngettext', 'wps_translate_words_array' );
function wps_translate_words_array( $translated ) {
  $words = array(
    // 'word to translate' = > 'translation'
    'Out of Stock' => 'YOUR_TRANSLATION',
   );
$translated = str_ireplace( array_keys($words), $words, $translated );
return $translated;
}

This should help.

Thank you,
Olivia

Hi, Do you mean that you vant to change the text of the Out of Stock control? In this case please try adding the following code to the Themler Settings >> CMS Code: add_filter( 'gettext', 'wps_translate_words_array' ); add_filter( 'ngettext', 'wps_translate_words_array' ); function wps_translate_words_array( $translated ) { $words = array( // 'word to translate' = > 'translation' 'Out of Stock' => 'YOUR_TRANSLATION', ); $translated = str_ireplace( array_keys($words), $words, $translated ); return $translated; } This should help. Thank you, Olivia
mrvargo
10 Posts
mrvargo posted this 6 days ago

That did the trick! Thanks very much

That did the trick! Thanks very much
Support Team
Support Team posted this 6 days ago

You are welcome. Feel free to contact us in any other occasion.

Sincerely,
Hella

You are welcome. Feel free to contact us in any other occasion. Sincerely, Hella
You must log in or register to leave comments