Hi @yoonlaserwp23
Is there any way that I can add the text without an additional plugin? My site already has too many plugins installed. That’s why. Also, I would like to know why editing the form-billing.php file doesn’t work.
Thank you for your reply and for providing more details about your situation. I completely understand your concern about adding more plugins to your site.
You’re absolutely right, you can add the text without needing another plugin. To do this, it’s best to utilize filters in your theme’s functions.php file.
The reason your edits to the form-billing.php file didn’t take effect is that WooCommerce, by default, loads templates from the plugin’s templates folder. Any changes you make to these files will be overwritten when the plugin updates. So, it’s better to override WooCommerce templates by copying them to your theme or child theme.
Let’s get to the solution now. You can change the ‘Create an account?’ text using the ‘gettext’ filter. Here’s a sample code for your theme’s functions.php file:
add_filter( 'gettext', 'change_create_account_text', 20, 3 );
function change_create_account_text( $translated_text, $text, $domain ) {
if ( 'woocommerce' === $domain && 'Create an account?' === $text ) {
$translated_text = 'Create an account? Your new text here.';
}
return $translated_text;
}
Just remember to replace ‘Your new text here.‘ with the sentence you want to add. It’s always a good idea to use a child theme when making these changes to avoid losing them when your theme updates.
You should add this code to your child theme’s functions.php
file or via a plugin that allows custom functions to be added, like the Code Snippets plugin. Please note that it’s not advisable to add custom code directly to your parent theme’s functions.php
file. Doing so could lead to the code being erased when the theme is updated.
?? Just a quick reminder: Before you make any changes, we strongly recommend that you create a backup of your full site and database. This is a crucial step to ensure that in case anything goes wrong, you can easily restore your site to its previous, functioning state.
I hope this helps! If you have any more questions, feel free to ask.