• Resolved padylee

    (@padylee)


    When I place an order and create a new account, I then receive an email with a link to set the password. That’s good, but the link text is in English. I would like to have the text in German. Is there a standard solution here? I don’t want to install a translation plugin for this one sentence.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Ahir Hemant

    (@hemant-ahir)

    You can change the link text in the password reset email without installing a translation plugin by adding a custom code snippet to your theme’s functions.php file or in a custom plugin. Here’s how to do it:Step 1: Add Custom Code

    1. Access Your Theme’s functions.php File:
      • Go to your WordPress dashboard.
      • Navigate to Appearance > Theme Editor.
      • Find and open the functions.php file for your active theme.
    2. Add the Following Code:
    add_filter('woocommerce_email_subject_customer_reset_password', 'ahirwp_custom_reset_password_email_subject', 10, 2);
    function ahirwp_custom_reset_password_email_subject($subject, $user) {
    return __('Passwort zurücksetzen', 'your-text-domain'); // Change the subject line here
    }

    add_filter('woocommerce_email_body_customer_reset_password', 'ahirwp_custom_reset_password_email_body', 10, 2);
    function ahirwp_custom_reset_password_email_body($body, $user) {
    // Use the text you want for the reset link
    $reset_link_text = 'Klicken Sie hier, um Ihr Passwort zurückzusetzen';
    $reset_link = '<a href="' . esc_url(wp_lostpassword_url()) . '">' . $reset_link_text . '</a>';

    // Replace the default link text with the new one
    $body = str_replace('Set your password', $reset_link, $body); // Adjust 'Set your password' to match the exact English text if needed

    return $body;
    }

    Save Changes

    • After adding the code, make sure to save the changes to the functions.php file.

      Thanks
      Ahir Hemant
    Plugin Support Reynier C. (woo-hc)

    (@reynierc)

    Hi @padylee ,

    I understand having the link text in German certainly makes sense for your customers. You don’t need a full translation plugin for just one sentence.

    The code snippet that @hemant-ahir shared should do the trick (by the way, thanks for sharing it!). Our support is a bit limited regarding custom code snippets, but I can confirm that this one should work.

    Just an added suggestion: to keep things tidy and avoid editing the functions.php file directly, you can use a plugin for code snippets, there should be a lot of options when you search the plugin library. It’s a safe and easy way to add custom code to your site. Just be sure to back up your site before making any changes.

    Hope this helps!

    Thread Starter padylee

    (@padylee)

    Thank you very much! Very friendly. I will test it.

    May I ask why this translation is not integrated by default in WooCommerce? Every user in Germany should have this problem.

    Plugin Support Reynier C. (woo-hc)

    (@reynierc)

    Hi @padylee ,

    Thanks for the response and for the question! To answer, WooCommerce aims to be as adaptable as possible globally, which is why it’s in English out of the box. Settings for specific languages or regions, like German for users in Germany, often require a bit of extra setup such as plugins or custom code to keep WooCommerce flexible for everyone, everywhere.

    We appreciate your understanding and are always here to hopefully help make your experience smoother.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.