Site logo

Archived topic

Out of Stock text

7 replies · Started by Ivan on May 25, 2020

Viewing posts 1–8 of 8

Hi all

I would like to change the text "Read More" for non stock products, I've found a tons of codes but none works with GeneratePress, could you help me? It has to be something easy :(

Hi Leo

This will hide the product and its not what I need as I have the option to receive an email when the product is again avaiable.

I had it working with a Plugin, but was too heavy just for this funcionality so this is why I would like a snippet, this is the one I found but not working if I put it on theme/functions.php :(

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;
}

Br
Ivan

This should change 'Out of Stock' text if that's what you need

add_filter( 'woocommerce_get_availability', 'db_custom_get_availability', 1, 2);
function db_custom_get_availability( $availability, $_product ) {

// Change Out of Stock Text
if ( ! $_product->is_in_stock() ) {
$availability['availability'] = __('Sold Out', 'woocommerce');
}
return $availability;
}

Nothing :( , maybe it’s due the translation that overlap the function? No clue...

That´s worked David, thanks!

Br
Ivan

You're welcome

This archived topic is closed to new replies.