This thread is resolved. Here is a description of the problem and solution.
Problem:
The client is experiencing an issue where email notifications sent from their multilingual e-commerce sites viviscal.bg and viviscal-store.com are displaying in multiple languages instead of just the language in which the order was made. This problem is linked to the YAY Mail plugin's handling of languages.
Solution:
We recommend updating the YAY Mail plugin's code to ensure that emails are sent in the correct language. Specifically, modify the
get_site_language
function in the WPMLIntegration.php file. Here's the step-by-step guide:
- Backup the original WPMLIntegration.php file located in /wp-content/plugins/yaymail-pro/includes/Integrations/Translations/.
- Replace the existing
get_site_language
function with the following code:
public static function get_site_language( $order ) { global $sitepress; $language = \defined( 'ICL_LANGUAGE_CODE' ) ? ICL_LANGUAGE_CODE : 'en'; if ( null !== $order || isset( $GLOBALS['yaymail_set_order'] ) ) { $order_data = ( null !== $order ) ? $order : $GLOBALS['yaymail_set_order']; // $order_language = $order_data->get_meta( 'wpml_language' ); $post_language_details = apply_filters( 'wpml_post_language_details', null, $order_data->get_id() ); $order_language = isset( $post_language_details['language_code'] ) ? $post_language_details['language_code'] : ''; if ( ! empty( $order_language ) ) { $language = $order_language; } } $sitepress->switch_lang( $language ); return $language; }with
public static function get_site_language( $order ) { global $sitepress; // Use default language as safe fallback $language = apply_filters( 'wpml_default_language', null ); if ( null !== $order || isset( $GLOBALS['yaymail_set_order'] ) ) { $order_data = ( null !== $order ) ? $order : $GLOBALS['yaymail_set_order']; $order_language = $order_data->get_meta( 'wpml_language', true ); if ( ! empty( $order_language ) ) { $language = $order_language; } } do_action( 'wpml_switch_language', $language ); return $language; } - After updating the code, test the email notifications to ensure they are now sent in the correct language.
If this solution does not resolve your issue or seems irrelevant due to updates or different configurations, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
This topic contains 22 replies, has 0 voices.
Last updated by 6 months, 2 weeks ago.
Assisted by: Kor.