Change In Stock Label in WooCommerce

Change In Stock Label in WooCommerce

As a WooCommerce store owner/manager, in some cases, you may need to change the “In Stock” text. In this article, Today we are going to talk about How To Change In Stock Label in WooCommerce. You can change it very easily by following the steps mentioned below:

STEP : 1 Go to your theme editor and find your active theme’s functions.php file.

STEP : 2 Copy the codes mentioned below and paste it to your functions.php file. Please make sure to take a backup of your functions.php file before making any changes.

/**
 * Change WooCommerce In Stock text 
 */ 


function fwp_change_in_stock_text( $availability, $_product ) {
    
    // Change In Stock Text
    if ( $_product->is_in_stock() ) {
        $availability['availability'] = __('Product Available on Request', 'woocommerce');
    }
   
    return $availability;
}
add_filter( 'woocommerce_get_availability', 'fwp_change_in_stock_text', 1, 2);

NOTE: Please make sure to change the text “Product Available on Request” according to your needs.

How to change In Stock and Out Of Stock text label in WooCommerce

Would you like to change the “In Stock” and “Out Of Stock” text conditionally? If Yes, Please follow the instructions mentioned below. In this case, you also need to find your active theme’s functions.php file and then you need to add a small code snippet to it.

/**
 * Change WooCommerce In Stock and Out of Stock Text Label
 */ 

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

Please note in this case you also need to change the text label according to your needs.

N.B. This is a developer-level tutorial. If you feel, it’s difficult to do for you. You may consider hiring me through Fiverr. I’ll fix your issue as soon as possible.

Table of Contents :

Leave a Comment

Your email address will not be published.