Change “in stock” / “out stock” text in Woocommerce single product page
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.