Site logo

Archived topic

woocommerce - change the out of stock message

3 replies · Started by Donna on June 2, 2018

Viewing posts 1–4 of 4

Hi
is there a simple way to change out of stock notice on a product to read sold out instead?

Thank you.

Hi Donna,

with this code snippet:

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

https://docs.generatepress.com/article/adding-php/

Thank you so much for that.
Where do I add it?

This archived topic is closed to new replies.