Background of the issue:
I am trying to translate a string that is output via a custom YayMail hook in WooCommerce transactional emails. The string is added to the email via a PHP hook and displays correctly in English. The domain shows as flatsome, and the string is visible in WPML's string translation table. Link to a page where the issue can be seen: hidden link
Symptoms:
The translated version does not show in the final email. Instead, I got the untranslated English string in the email, despite the translation existing in WPML's String Translation.
Questions:
Why is the translated string not appearing in the email?
How can I ensure the translation is applied correctly in WooCommerce emails?
Thanks for your response.
However, the content I'm trying to translate is not added manually via YayMail's extra content editor. Instead, it’s injected programmatically via the woocommerce_email_before_order_table hook using a custom function.
What else is needed from my end for debugging?
Thank you in advance!
1) You mentioned woocommerce_email_before_order_table, that is WC hook, so the issue should happen also without YayMail addon, right? Can you please test?
/**
* Save Data Not VAT Invoice.
*
* @param int $order_id Order ID.
*
* @return void
*/
public function save_date_not_vat_invoice( int $order_id ): void {
update_post_meta( $order_id, '_not_vat', ! empty( $_POST['not_vat'] ) ? 'yes' : 'no' );
thanks, so as I can see, you are editingthe Flatsome child theme and adding custom code/string there.
1) Does the issue happen with only WPML plugins and WooCommerce, all other disabled?
2) Are you adding any other custom code to your child theme?
3) If the issue still happens after step 1, can you please go to the next test site and try to reproduce the same issue. Share steps with me what have you done.
I suspect issue is with custom code, but since we can not support custom code / solutions I am trying to see the issue in example / minimal test site, so I can easily consult with our 2nd tier.
1. Plugin Deactivation:
Due to the complexity of our site and the fact that everything else — including WooCommerce, YayMail, and other plugins — functions correctly, we're unable to deactivate all plugins. The issue seems to be isolated to WPML not applying translations when the strings are inserted via hooks in WooCommerce email templates.
2. Custom Code:
Yes, we are using some custom code in the child theme to extend functionality not available out of the box. However, the strings are wrapped in `__()` with the correct text domain and show up correctly in the WPML String Translation interface. The issue is not with them registering — it’s that WPML doesn’t apply the translations in this context.
3. Sandbox Testing:
I understand the need for a minimal test case. However, since this is a custom WooCommerce/YayMail integration that reproduces fine on our live site, could you please confirm if WPML supports translation of strings added via `woocommerce_email_before_order_table` hooks? If so, we’ll do our best to replicate it on the sandbox.
4. Environment Details:
Here are our current environment details for reference:
1) I know, but we need to confirm if issue is related to only WooCommerce or any other plugin or your website specifically, so that is one way to move forward with debugging the issue.
3) I think it should support. What you can try is add a string as in our example docs, see if that translates and if yes adjust your current code with same.
If nothing helps, then the best and quickest would be to move with a sandbox test website, reproduce the case, and then I can consult further on this with our 2nd tier.
Thank you for your pieces of advice.
This is helped:
<?php printf( _e(
The ticket can be closed.
BR,
Elizabeth
Manage Cookie Consent
We use cookies to optimize our website and services. Your consent allows us to process data such as browsing behavior. Not consenting may affect some features.
Functional
Always active
Required for our website to operate and communicate correctly.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
We use these to analyze the statistics of our site. Collected information is completely anonymous.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
These cookies track your browsing to provide ads relevant to you.