Issue
I'm facing a problem to change the "Create an account" text on the checkout page of woocommerce. I searched on Google but didn't find any result. How to modify the text?
Solution
There's no need to modify the template you can use a filter to change the text. Copy and paste into your theme's functions.php file. It's a much cleaner solution as template files may need updating in the future.
function my_text_strings( $translated_text, $text, $domain ) {
    if ( 'woocommerce' !== $domain ) {
        return $translated_text;
    }
    
    switch ( $translated_text ) {
        case 'Create an account?' :
            $translated_text = __( 'This is the new text that will be displayed!', 'woocommerce' );
            break;
    }
    return $translated_text;
}
add_filter( 'gettext', 'my_text_strings', 20, 3 );
                        
                        Answered By - Andrew Schultz Answer Checked By - David Goodson (PHPFixing Volunteer)

0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.