hyyan / woo-poly-integration

Looking for maintainers! - Wordpress WooCommerce Polylang Integration
https://wordpress.org/plugins-wp/woo-poly-integration/
MIT License
183 stars 66 forks source link

Emails without order not translated correctly #556

Open cebbinger opened 3 years ago

cebbinger commented 3 years ago

I tried to add and translate additional content to some emails that are sent to the user. Unfortunately, the text is not translated.

Can you reproduce this issue on default Wordpress theme (eg Storefront)?

Yes.

Can you reproduce this issue when all other plugins are disabled except WooCommerce, Polylang and Hyyan WooCommerce Polylang Integration?

Yes.

What product versions and settings are you using when this issue occurs?

Steps to Reproduce

  1. Add additional content to an email not related to an order. (for example: lost password)
  2. Translate the text using Polylang.
  3. Trigger the email with additional content. (for example: click "Lost your password?" on account page)

What I Expected

I expected to see the translated additional content in the email.

What Happened Instead

I saw the original, untranslated text in the email.

cebbinger commented 3 years ago

Apparently, the plugin skips applying the translation ($string_template) if the $target_object is not a WC_Order.

https://github.com/hyyan/woo-poly-integration/blob/b43c4949f60740a9fd339500f7c2674854c94892/src/Hyyan/WPI/Emails.php#L485-L497

For my individual case, the problem seems to be solved by adding the following code before returning $formatted_string in line 497:

else {
    return $email_obj->format_string($string_template);
}

I'm not sure if that works in other configurations, too.