How many times did you encounter a “Add to Cart” button or “View Cart” button on your WooCommerce website and you wanted to change it to something else, and didn’t know how?

In this code snippet we can change any string we want (as long as it’s not a string with variables, it may be harder).

In the following example we used that snippet to change WooCommerce’s ‘View Cart’ button’s text to ‘View Shopping Cart’. As you can see, we also replaced ‘Categories’ and ‘Recent Posts’ phrases to other values. Make sure you specify the correct text domain instead of ‘theme_domain’ as in the code example.

function new_text_strings( $new_text, $text, $domain ) {
    switch ( $new_text ) {
        case 'View Cart' :
            $new_text = __( 'View Shopping Cart', 'woocommerce' );
            break;
		case 'Categories' :
            $new_text = __( 'Topics', 'theme_domain' );
            break;
		case 'Recent Posts' :
            $new_text = __( 'Newest Posts', 'theme_domain' );
            break;
    }
    return $new_text;
}
add_filter( 'gettext', 'new_text_strings', 20, 3 );

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

We are sorry that this post was not useful for you!

Let us improve this post!