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 12 replies, has 2 voices.

Last updated by Bruno 1 year, 9 months ago.

Assigned support staff: Bruno.

Author Posts
June 1, 2017 at 11:39 am #1289340

szilardM-2

Hi there,

I have one product. I use Woocommerce Multilingual to translate this product to different languages. I use Woocommerce Follow Up Emails to send out one 'order completed' email for each translated product. Please check this screenshot: hidden link
So I have one email for every language.
I tested it with my already registered test customer and it was working fine. If I buy the English version of the product then I receive the english email. If I buy the French translated product I receive the French email, and so on. So everything seemed working fine with this set-up.
But as it turned out if a new customer is purchasing the products they will receive the English email regardless of their selected language. By purchasing the product they are forced to register a new account because the product comes with membership as well. And after this first purchase if they purchase any more times this product, as now a registered user, they always receive the right language email. So after the first purchase what comes with registration everything is working fine.
Please check this 2 screenshots. Both order was made using the Japanese language. But in the first case, when it was the user's first purchase, the English email was sent out. In the second case the same user purchased that product again and the good, Japanese email was sent out. And after it they could choose any language for new purchase and they got the email with the right language.
hidden link
hidden link

Do you now what can cause this issue? So if there is a new customer, then their first purchase doesn't trigger the right version of the translated product but the original, but after that it just works fine with any other purchase.

The language of the order is captured fine even during the first purchase as you can see here:
hidden link

Any idea how to solve this?

Best,
Szilard

June 2, 2017 at 12:31 pm #1290165

Bruno
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi,

Apparently, this may be a compatibility issue, as this plugin is not in our list of officially compatible plugins: https://wpml.org/documentation/plugins-compatibility/

Please, could you send me this plugin so I can test it in my testing environment?

If so, you can upload the plugin for some service like Google Drive or Dropbox and send me the link so I can download it. Your next answer will be private.

Thank you.

June 2, 2017 at 8:49 pm #1290516

Bruno
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi,

Thank you. I've downloaded the plugin you posted. When I test this in my test environment, both emails from the languages are sent.

I need to request temporary access (wp-admin and FTP) to your site - preferably to a test site where the problem has been replicated if possible - in order to be of better help.

You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

*** Note: Please make a full backup of your site.

Privacy and Security when Providing Debug Information for Support: https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

Thank you.

June 3, 2017 at 3:46 pm #1290677

szilardM-2

Hi,

I tested it more. Now I can tell, that it depends on if the customer is already registered or they are new customers who register during checkout.
I created a new customer account from wp-admin. I logged in with the new user and purchased my first product. And the email that was sent out was in the correct language.
But if I purchase as a new customer and register during checkout (not in advance) then I receive the original (English) email regardless of my language during checkout. And after that as I am already registered all my emails for new purchases are sent out in the correct language I used for checkout.

So something goes wrong when a new customer purchase and register at the same time during checkout.

Best,
Szilard

June 3, 2017 at 3:55 pm #1290682

szilardM-2

And it seems it is true for checking the product IDs that a customer has purchased as well.
For other reason I use wc_customer_bought_product() and if the customer was registering during checkout then wc_customer_bought_product() is true for the original product ID. But if the customer was already registered during checkout then the function is true for the translated product ID and not for the original ID.

Best,
Szilard

June 5, 2017 at 10:01 pm #1291736

Bruno
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi Szilard,

Sorry for the delay. I saw the problem you're reporting.

I'm going to test a little more in my testing environment to check this out. This seems, however, a compatibility issue as long as the configuration is done correctly. I'll contact you soon.

Thank you.

June 5, 2017 at 11:23 pm #1291756

Bruno
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi,

I will contact the 2nd tier support and soon I will contact you.

Thank you.

June 6, 2017 at 6:24 am #1291835

szilardM-2

Hi,

Thank you.
Do you think it is a compatibility issue with Follow Up Emails?
Because as I said the same is happening if I use the wc_customer_bought_product() function what has nothing to do with the Follow Up Emails extension.

Best,
Szilard

June 6, 2017 at 8:17 pm #1292586

Bruno
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi,

Yes. This seems to be a compatibility issue. I've forwarded your ticket to our compatibility team. Note that at the moment I do not have a workaround and I do not have a deadline when this should be fixed.

About using the wc_customer_bought_product() function, you must use the correct product ID. If you are trying to retrieve information from a product in another language, you must use the WPML filter "wpml_objects_id". You can see more in our documentation: https://wpml.org/wpml-hook/wpml_object_id/

Thank you.

June 7, 2017 at 6:27 am #1292764

szilardM-2

Hi Bruno,

Thanks for the info.

Best,
Szilard

August 1, 2017 at 9:28 pm #1332761

Bruno
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi,

Sorry for the delay. Our compatibility team has created this little fix to solve the problem. Add the code below into the functions.php file of your theme:

add_filter( 'fue_get_emails_args', function( $args ) {
    $args['suppress_filters'] = false;
    return $args;
} );

add_filter( 'fue_queue_item_filter_conditions_before_sending', function( $send, $queue_item ) {
    global $sitepress;

    $language = get_post_meta( $queue_item->order_id, 'wpml_language', true );
    $sitepress->switch_lang( $language );
    $sitepress->set_admin_language( $language );

    return $send;
}, 10, 2 );

Also, make sure also that you are translating the email, rather than creating a new one on the secondary language. I'll attach an image for you to see. Then, you can in the Follow-up Email translation, configure the same way you have set it in the original language.

After following these steps, please let me know if this is working properly.

Thank you.

August 2, 2017 at 7:11 am #1332879

szilardM-2

Hi Bruno,

Thanks a lot for your help. I am on holiday atm, but will check once I am back.

Best,
Szilard

August 2, 2017 at 1:03 pm #1333235

Bruno
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi,

Sure. Please, after you test this, let me know if it's working correctly sending emails in both languages.

Thank you.