Modify checkout text in WooCommerce –

WordPress allows us to modify some texts without having to use plugins, in this case we are going to modify the WooCommerce checkout texts, we will only have to add some function to our Functions.php file.

Hosting Mautic QuickStart -50% with support in Spanish
24 hours and free training

Send up to 1,000,000 emails/year. Mautic support in Spanish 24 hours, 365 days

Access your account >

Access the folder your wp-content installation > themes > Theme used or child theme that is being used and edit the file functions.php

Add the following to the end of the functions.php file

/** * Switch texts in WooCommerce/WordPress */ function my_text_strings( $translated_text, $text, $domain ) { switch ( $translated_text ) { case ‘Billing details’ : $translated_text = __( ‘your text here! ‘, ‘woocommerce’ ); break; case ‘Ship to a different address?’ : $translated_text = __( ‘your text here’, ‘woocommerce’ ); break; } return $translated_text; } add_filter( ‘gettext’, ‘my_text_strings’, 20, 3 );

Understanding the code a little more we have the following setting:

case ‘billing details‘ :
$translated_text = __( ‘your text here!‘, ‘woocommerce’ );

In this we can see that WordPress is requested to make the change of Details of billing to your text here! in case we need to add more translations (from WooCommerce) we could add the following line:

case ‘Ship to a different address?’ : $translated_text = __( ‘your text here’, ‘woocommerce’ ); break;

An example with several texts could be the following

/** * Switch texts in WooCommerce/WordPress */ function my_text_strings( $translated_text, $text, $domain ) { switch ( $translated_text ) { case ‘Billing details’ : $translated_text = __( ‘your text here! ‘, ‘woocommerce’ ); break; case ‘Ship to a different address?’ : $translated_text = __( ‘your text here’, ‘woocommerce’ ); break; case ‘New text to translate’ : $translated_text = __( ‘New text here’, ‘woocommerce’ ); break; } return $translated_text; } add_filter( ‘gettext’, ‘my_text_strings’, 20, 3 );

See also  How to create a blog in WordPress in 2022 -

In this way we can change the WooCommerce texts, without the need to install a plugin just to make small changes.

Help us improve our content by sharing your opinion

WordPress and WooCommerce support team at .

Loading Facebook Comments ...
Loading Disqus Comments ...