Search
Generic filters

WooCommerce- How to change ‘In Stock’ / ‘Out of Stock’ text displayed on a product page

By Cronos Editorial Staff on May 6, 2022

WooCommerce- How to change ‘In Stock’ / ‘Out of Stock’ text displayed on a product page

change ‘In Stock’ / ‘Out of Stock’ text in WooCommerce

Log in to the WordPress admin panel, navigate to the Appearance -> Editor tab and open the custom-functions.php (or Function.php of your main theme) file for editing:

WooCommerce. How to Change In Stock Out of Stock text displayed on a products page 1 1024x555 1

Add the following code to the bottom of the custom-functions.php (or Function.php of your main theme) file. You can change the Available! and Sold Out text to be whatever you like:

				
					add_filter( 'woocommerce_get_availability', 'wcs_custom_get_availability', 1, 2);
function wcs_custom_get_availability( $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;
}
				
			

Articles

Services

Home

About

Contact

2022 Cronos Inc. © ®

Share

WooCommerce- How to change ‘In Stock’ / ‘Out of Stock’ text displayed on a product page

WooCommerce- How to change ‘In Stock’ / ‘Out of Stock’ text displayed on a product page

Cronos - May 6, 2022

OR SHARE THIS LINK:

				
					https://cronosasia.com/wordpress/woocommerce-how-to-change-in-stock-out-of-stock-text-displayed-on-a-product-page/