I'm creating a Wordpress website with Woocommerce and am using variable products. I know how to change the out of stock text for the variants of the product, but I would like to know how to change the out of stock text when I have no variants added at all (i.e. set the product type to variable product and add no variants).
As it stands, the text that is shown by default is: "This product is currently out of stock and unavailable."
How would I go about changing that text?
Really easy to achieve this with the gettext filter.
function modify_gettext( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'This product is currently out of stock and unavailable.' :
$translated_text = __( 'This is my new out of stock text', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'modify_gettext', 20, 3 );