Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
- - 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00
- - - - - - -

Supporter timezone: America/Lima (GMT-05:00)

This topic contains 20 replies, has 2 voices.

Last updated by Andreas W. 1 year, 9 months ago.

Assisted by: Andreas W..

Author Posts
May 23, 2022 at 11:19 am #11279403

nouraZ

Hello, my currency switcher only works when logged in but most users will not be logged in. Help please?

May 26, 2022 at 1:24 pm #11316613

nouraZ

Hello, the issue seems to be from caching. unfortunately, I am unwilling to turn off caching as its an e-commerce site that's heavy on images. any workaround available for this?
Note: my caching is directly from my hosting and not a plugin.

May 27, 2022 at 5:38 am #11322435

Andreas W.
Supporter

Languages: English (English ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

This means clearing the server cache solves the issue?

Would you be able to set up a clone or staging site of your site on the same server so that we can debug this issue?

If so, I have enabled the private reply form so that you can provide us access.

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.

IMPORTANT

Please make a backup of site files and database before providing us access.
If you do not see the wp-admin/FTP fields this means your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this:
hidden link

The steps are also shown in this video: hidden link

Best regards
Andreas

June 1, 2022 at 1:29 am #11358315

Andreas W.
Supporter

Languages: English (English ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

The staging has additional directory protection which so I can not access the login form.

I have enabled the private reply form again so that you can provide me access.

Best regards
Andreas

June 2, 2022 at 5:14 am #11368413

Andreas W.
Supporter

Languages: English (English ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

The user/pass for a site for the site protection seems not to be valid.

Could you please verify again and edit the earlier provided private messages again?

Please leave me a short notification on this ticket, once access is granted.

Best regards
Andreas

June 4, 2022 at 9:53 am #11387667

nouraZ

Hello Andreas, Thanks for your response. I've edited the details and await your reply.
Thank you again, Noura

June 6, 2022 at 11:34 am #11395413

nouraZ

Hello again Andreas,
Just wanted to check in and see if there was any progress with my case?
Thanks

June 7, 2022 at 12:02 pm #11403777

nouraZ

Hello, I hope all is well.
I urgently need help with this issue.
Please get back to me soon.
Thank you
Noura

June 7, 2022 at 7:47 pm #11407217

Andreas W.
Supporter

Languages: English (English ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

My apologies for the delay as I do not work on Sundays and Mondays.

I am able to reach the WP Login now but when trying to log into the staging I get:

ERROR: Incorrect username or password.

Could you please verify the login credentials?

Best regards
Andreas

June 8, 2022 at 4:15 pm #11416605

nouraZ

Hello Andrea,

Thank you for your reply! Sorry I didn't take into consideration the weekend 🙂
I have been able to create a new account as the old one wasn't working.

All the details are the same as mentioned earlier except the username is now "support2"
Sorry I can't retype them as the private reply is not showing up for me right now.

Looking forward to hearing back from you.

Have a great day ahead!
Noura

June 9, 2022 at 12:15 am #11418561

Andreas W.
Supporter

Languages: English (English ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello Noura,

Thank you for the access to your staging site.

Take note, that am experiencing random 502 Bad Gateway errors on the staging. Do you also get such errors on your live site?

The first thing I realized here is that the WooCommerce Multilingual Setup Wizard was not completed yet.
Do you still see a notification on your live site dashboard that you need to run this setup?

See screenshot.

After running the WCML setup wizard I also ran all available plugin updates.

I still can see the reported issue, even when testing only with WooCommerce and WPML on the default Twenty Twenty One Theme which is why I have created a test site in order to try to recreate this issue, but I can not confirm such behavior on a new test site in almost similar setup (not using fixer.io here):

Example:
hidden link

Sidenote:
Take note that on your site, when visiting the product without being logged in, I see the following error on the browser debug console:

Mixed Content: The page at 'hidden link' was loaded over HTTPS, but requested an insecure element 'hidden link'. This request was automatically upgraded to HTTPS, For more information see hidden link

Now, this mixed content error can occur if you upload media onto the site while the site was using only the "http" protocol, and then after an SSL certificate was added and the site runs on "https" it can produce this error, of the old media still uses "http" in its source.

This is not a WPML error, but this error could stop the browser from executing the JavaScript functions on the website, as the browser produces a block.

Here is a guide about how you could solve this mixed content error:
hidden link

Please verify if you see such an error on your live-site product when checking the browser debug console. (Windows Ctr + Shift + J)

The mixed content error points to this image:
hidden link

Which seems to have been uploaded to your site as:
hidden link

As this upload link does not use HTTPS it is causing an error.

You can use this free plugin in order to search and replace database entries:
https://wordpress.org/plugins/better-search-replace/

Search for http:// and replace it with https://

Please make sure to take a backup of the live site before running this task.

Doing this, solved the mixed content error on your site, but anyhow I still see the issue with the currency switcher, when not being logged in.

I then deactivated fixer.io (Automatic Exchange Rates) for testing but It still does not change the fact, that we can not switch to another currency but the WooCommerce site default currency when not being logged in to the site.

So far I was not able to recreate this issue on a new test site I would like to ask you for some more patience, as will need some more time in order to investigate this issue and I hope for your understanding.

Best regards
Andreas

setup.jpg
June 9, 2022 at 11:23 am #11423897

nouraZ

Hello Andreas, Thank you for your super informed reply! I will go ahead and do the things you suggested and get back to you..

In regards to the Bad gateway, I've run into the same only on the staging site, the live site is fine..

As for the setup wizard, we are not ready to make the translations yet and this is why it is not yet set up. for now we just need the currency converter and will add another language in the future, which is why we decided to go with wpml as it will provide both when we need it to.

As for the main issue of the currency not switching, I should note that my hosting has caching from the hosting side. And it seemed from my conversation with their support as well as from the research I did into this that it is indeed related to caching.. When I turned caching off through my hosting provider the issue disappeared.

I've tried adding this snippet to my functions file:

// currency switcher fix
function wcml_set_custom_currency_cookie( $currency = false ) {if ( is_admin() && !( defined(‘DOING_AJAX’) && DOING_AJAX ) )return;if ( !empty( $currency ) ) {setcookie(‘wordpress_wcml_custom_currency_cookie’, $currency, time() + 60*60*24*7, ‘/’);return;}if ( empty( $_COOKIE[‘wordpress_wcml_custom_currency_cookie’] ) && function_exists( ‘get_woocommerce_currency’ ) ) {setcookie(‘wordpress_wcml_custom_currency_cookie’, get_woocommerce_currency(), time() + 60*60*24*7, ‘/’);}}add_action(‘wcml_switch_currency’, ‘wordpress_wcml_custom_currency_cookie’);add_action(‘init’, ‘wordpress_wcml_custom_currency_cookie’);

But it did not seem to work every time.

Please see below the reply from hosting regarding the issue since it seems directly related to caching...

---
it sounds like caching can be to blame for the issues here since it worked when developer mode was enabled. By default, we have Woocommerce paths (/checkout, /account, etc) excluded from the cache, but there may be custom paths or cookies that need to be excluded for the WooCommerce Multilingual plugin.

When it comes to caching and caching exclusions on Flywheel, we're more than happy to get a page or set of pages excluded from cache. But when it comes to excluding cookies from the cache, it gets a little more complicated.

Normally adjusting the Nginx configuration to exclude cookies would work, but Fastly (our CDN/Caching layer) complicates this. Attempting to force NGINX to tell the Fastly layer what cookies to bypass is not very reliable, but there is a workaround. We use a global rule for our Fastly layer, there are a few cookie prefixes that we bypass cache on by default. One of those prefixes is wordpress_. So if a site is caching a cookie that needs to be excluded from the cache, you can just add the wordpress_ prefix to the cookie and it will be excluded from cache.

Just let us know if there are any specific paths that the WooCommerce Multilingual plugin needs to be excluded, and we'll be happy to exclude those from caching. Otherwise, using the above workaround for excluding cookies would be the route to go if any cookies need to be excluded.

A path is basically just a page, so for example, /available-watches would be a path or /cart. Flywheel excludes Woocommerce paths from caching by default. So the widget area isn't really considered a path, but it more than likely sets or edits a cookie.

I think it may be best to reach out to the WooCommerce Multilingual plugin support team about the issue, and find out what cookie handles this and if it is possible to edit the cookie. Once you know what cookie it is, and how to edit it, then you can implement the workaround I mentioned earlier to prevent that cookie from caching.

I know this seems pretty convoluted, or clear as mud, but I think getting support from the plugin developers would be the best bet. They'll be able to provide more plugin-specific troubleshooting to help out. Plus, we are always here in case they need anything from the hosting side of things!
---

Looking forward to hear back from you.

June 9, 2022 at 10:29 pm #11428305

Andreas W.
Supporter

Languages: English (English ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Yes, indeed something like this had been reported earlier and our developers had been working on achieving compatibility with the most commonly used Cache plugins for WordPress.

https://wpml.org/errata/caching-plugins-may-cause-issues-with-wcml-multi-currency-settings/

In your case, it appears to be a Flywheel Hosting specific case, that we are not able to recreate on another server while taking a copy of your site. I can not confirm the issue anymore when running a copy of your site on a local, virtual server (running on Local by Flywheel - see screenshot).

About FlyCache:
"If the page is cached, the cookie cannot be generated and perform its certain action when the page is loaded as expected."

Source:
hidden link

Now, it does not look to me as if WPML would not be able to set a language cookies, as it does in this case, and I am not sure what is actually causing the issue.

Flywheel is providing a workaround in the above-mentioned documentation.

Apart from that FlyCache is not a plugin and is implemented into their servers.

FlyCache by default does not cache specific WordPress and WooCommerce pages, which for you will not run in such issues if the pages are excluded from cache. In your case actually, any product page would need to be excluded from FlyCache as well, and the currency feature should work as expected.

hidden link

Did you ask the Flywheel Support if they could achieve that? In your case, I would try to exclude anything that comes with www-sitename.com/product/

I am further escalating the staging access for your site towards our second-tier support, but you will need to make sure that the access stays granted for further investigation.

Once I got more feedback from our team I will be in contact.

Best regards
Andreas

June 12, 2022 at 4:39 pm #11443325

nouraZ

Hello Andreas, thanks for your reply. If I remove the caching from all my products then I won’t be if it from the image caching.. that’s my issue and why I don’t want to turn off caching. Also, I will be required to exclude every product i upload forever which is not very convenient..
is this the only option I have?
And will I have the same issue with the currency converter?
Thanks
Noura

June 14, 2022 at 7:16 am #11454899

Andreas W.
Supporter

Languages: English (English ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

My apologies for the delay, as I do not work on Sundays and Mondays.

Could you please try adding this to your theme's functions.php file?

add_filter( 'wcml_is_cache_enabled_for_switching_currency', '__return_true' );

I would have applied this for you, but sadly I do not have access to the files.

Please let me know if it solved the issue.

Best regards
Andreas

The topic ‘[Closed] my currency switcher only works when logged in’ is closed to new replies.