Change Woocommerce Stock Message on ProductPage

This snippet makes some frontend magic. It changes the default Available/Out of Stock messages to your desired custom message. You can display anything you want.

/** * Change Availability/Stock Messages * **/

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

    // Change Out of Stock Text
    if ( ! $_product->is_in_stock() ) {
        $availability['availability'] = __('No more stock', 'woocommerce'); //Change "No more stock" to your desired message
    }
    return $availability;
}



    // Change In Stock Text
    if ( $_product->is_in_stock() ) {
        $availability['availability'] = __('Stuff There!', 'woocommerce'); //Change "Stuff There!" to your desired message
    }

WHERE TO PLACE THIS CODE?

Copy the snippet to your active child themes functions.php and dont forgot to save it.

Pleasure?

Please share your thumbsup, suggestions, edits, and questions within my comment section down there. 

I love posting snippets for you, but with a bit of feedback, it gets even more fun. 😀

Sharing is caring:

Share on xing
Share on linkedin
Share on whatsapp
Share on facebook
Share on twitter
Share on email

Leave a Reply

Your email address will not be published.