Home » Php » php – Changing WooCommerce out-of-stock-label text

php – Changing WooCommerce out-of-stock-label text

Posted by: admin February 25, 2020 Leave a comment


I simply want to change the text of the label ‘OUT OF STOCK’ to ‘SOLD OUT’ on my the bottom of the thumbnail on my WooCommerce category pages – https://watkinsprints.co.uk/category/cards/valentines/

EDIT: Relating to the answer below – I already have this code in place and it is used to change the ‘Out of Stock’ text on the product pages which is NOT what I’m after, it’s the Out of stock banner label on the category pages I wish to change.

Hope this is clear enough, many thanks!

How to&Answers:

Try This code—

add_filter( 'woocommerce_get_availability', 'db_custom_get_availability', 1, 2);

function db_custom_get_availability( $availability, $_product ) {

    if ( ! $_product->is_in_stock() ) {
        $availability['availability'] = __('Sold Out', 'woocommerce');
    return $availability;