Override translations

gettext

Override “Add to Cart” etc for virtual products in WooCommerce

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
<?php
add_filter( 'gettext', 'studio_gettext', 10, 3);
 
function studio_gettext( $translation, $text, $domain ) {
    if ( 'woocommerce' === $domain ) {
 
        global $product;
        if ( '%s in stock' === $text && $product->is_virtual() ){
            $translation = 'Available %s persons';
        }
        if ( 'Add to cart' === $text && $product->is_virtual() ){
            $translation = 'Sign up';
        }
    }
    return $translation;
}
?>