Change “in stock” / “out stock” text in Woocommerce single product page

  • August 25, 2022

In this tutorial you will learn how we can change “in stock” / “out stock” text with the custom. We will use custom snippet for this.

 * @snippet: Change stock availability text in single product page
 * @author: Deep P. Goyal

add_filter( 'woocommerce_get_availability', 'wpexpertdeep_change_availability_text', 1, 2);
function wpexpertdeep_change_availability_text( $availability, $_product ) {
    // Change In Stock Text
    if ( $_product->is_in_stock() ) {
        $availability['availability'] = __('Available!', 'woocommerce');
    // Change Out of Stock Text
    if ( ! $_product->is_in_stock() ) {
        $availability['availability'] = __('Sold Out', 'woocommerce');
    return $availability;

Just copy the above snippet and paste in your active theme’s functions.php file.

Related Post


Change product price in cart programmatically

Here we will learn, how we can change product price in cart programmatically. Add below code in your theme’s functions.php file


Change Woocommerce sold individually product setting Programmatically

Let’s assume you have a product inventory of 1000s of product and you want to sell your all product individually, what will you? Well you need to change the product setting one by one to […]


Remove Added to Cart Message in Woocommerce

If you are looking a way to hide “added to cart message” with easy method? Then you are in right place. To we will learn how to remove the “added to cart message” without using […]