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

Last updated by Bruno Kos 5 months, 3 weeks ago.

Assigned support staff: Bruno Kos.

Author Posts
April 24, 2019 at 9:15 am #3670899

matthewL-8

I am tearing my hair out after a fortnight of terrible support from Bruno who failed 100% to understrand the issue and just sent me unhelpful commetns once a day, as he was in a timezone 100% different to mine.

I have a issue with a LOGGED in user where the cookie
_icl_current_language
does not always change as expected
eg the user logs in to a spanish page - the cookie is "en"
this causes problems when posting to the cart on a special page as we use variants and so the spanish attributes are diffferent to the english ones - and we get an "invalid value" response.

I would like to know how i can set the _icl_current_language cookie manually please.

oh its also still broken with woocomerce 3.6.1 - that needs an urgent fix - but the issue is live in other threads.

April 24, 2019 at 10:25 am #3671509

matthewL-8

Ok to try and help explain better - in my case this is occuring on a page with a plugin.

if i go to a product page - the cookie changes as expected, i return to the page where the plugin is loading a widget - the incorrect language is restored.

So i tried the following experiment - in the plugin code where the widget is outputed.

1 - i outputted the language Cookie
2 - i updated the language cookie
3 - i created a different cookie to test

what happens is

1 - language is outputted correctly as ES
2 - cookie is changed corerctly to es
3 - test cokkie is corerctly created as es

but then after page load - soemthing INCORRECTLY updates the cookie back to "en"

I made a movie to show this.

So what is changing my LOGGED in user's cookie on a non woocommerce page back? How can i stop it. ICL_LANGUAGE_CODE is fine until page laod - so i am guessing some javascript is updating it.

screenshot link hidden link

April 24, 2019 at 12:49 pm #3672983

Bruno Kos
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

I've checked that other thread and I can see that Bruno (it is the other Bruno) has already escalated the issue. I have a question - is this cookie thing related exclusively to WPML cookie handling, or when you say:

i return to the page where the plugin is loading a widget

do you have some custom plugin that is also somewhere in between WPML and WooCommerce, or are you referring to a bug in the way how WPML does it?

If that's the case, I am wondering the following - could you make the same (minimal) setup on our sandbox so that we can test there, reproduce and send all of this info to our 2nd tier? Or may I ask if you have another idea how we can test this, trace the bug and provide a possible fix or a workaround?

Sandbox minimal installation is how we do this before sending this to our developers.

Let me know how you want me to handle this ticket or if you agree with my approach.

Regards,
Bruno Kos

April 24, 2019 at 1:14 pm #3673325

matthewL-8

Hi Bruno, thank you for your time.
I first want to say this issue doesnt always occur. There is some unique set of circumstances that make it happen - and of course it happened with our first live customer....
We dont know exactly what they are.
I am using a "product tables" plugin. I have this product table placed as a wdiget on a page.
I have a number of options for the buy button - when i use wordpress buy button with a dropdown select for the variants it seems to work. But my client want the version where each variant is shown as a radio button.
I have found through hours of extensive testing that when the cookie is correct, the page works, when the cookie is incorrect the page fails.
This makes sense because the variants attributes are different at different languages.
The issue is the same if we post or do an ajax call.
The only solution has been when i manually change the cookie in the storage part of my inspector.
So something is forcing the cookie to the "wrong" language - the default language, but that might be coincidence.
I can try and set this up on your sandbox, I can also take instruction (i just dont know where the ocokie stuff is in your code). I am concerend that you might struggle to reproduce the issue.
When the other bruno tried it worked ok for him. But he didnt follow my instructions step by step, so its hard to tell.
Testing cookies is a nightmare as its hard to get to a virgin state.
But today the client came from a virgin state and had the issue. I did the same as the client and could reporduce the issue.
Any help you could offer would be amazing. Its sooooo frustrating - i can see the problem, but dont know how to change it.
Trying to force the cookie in the plugin code, had no effect as it was overwritten almost instaneously.
Many thanks
Matt

April 24, 2019 at 2:23 pm #3673953

matthewL-8

Hi - further investigation leads to perhaps an interesting point.
When i browse normal pages (including the one with my product table widget) - the _icl_current_language goes to spanish but is reset back to english
when i browse woocommerce pages - the _icl_current_language is the expected spanish.
so the question is why would the _icl_current_language be incorrect on non woocommerce pages

April 24, 2019 at 2:44 pm #3674317

Bruno Kos
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

so the question is why would the _icl_current_language be incorrect on non woocommerce pages

And this:

I did the same as the client and could reporduce the issue.

In other words, you can definitely reproduce and provide these instructions on how we can do it as well? If yes, please check my next private message for Sandbox info and let's see if we can emulate it there.

Regards,
Bruno Kos

April 24, 2019 at 2:59 pm #3674441

matthewL-8

Hi Bruno
I think i may be closer to a solution.
Discovering the issue seems to be related to the presence of woocommerce, i have been looking at the site, we use a plugin wp-disable - this allowed woocommerce script and styles to be disabled on non woocommerce pages - i tried turning this setting off - but no joy - however i then went on and disabled cloudflare and removed that plugin totally.
Now on my two browsers the issue seem resolved.
However..... it could just be my browsers are no longer virgin (despite chrome incognito mode)
So i am going to see if the clients issue is solved, and leave this for a few days again to see whether this reoccurs.
Could you please ask the code guys if i am looking at this right, because it seems strange that the _icl_current_language should be incorrect on non woocommerce pages.
thanks
Matt
PS thanks for the quick replies

April 24, 2019 at 4:53 pm #3675397

Bruno Kos
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

So i am going to see if the clients issue is solved, and leave this for a few days again to see whether this reoccurs.

The ticket will remain open until you decide otherwise :).

so the question is why would the _icl_current_language be incorrect on non woocommerce pages

It may be site specific (or something related to your combination of Cloudflare and that plugin that you were using) - however, if you find that it still doesn't work, even on our caching-free sandbox site, then this is something we should escalate for debugging.

Regards,
Bruno Kos

The topic ‘[Closed] _icl_current_language not setting correctly for logged in users’ is closed to new replies.