Resolved

Reported for: WPML Multilingual CMS 3.6.3

Resolved in: 3.7.0

Symptoms

To solve certain issues with caching plugins we are no longer setting the language cookie on front-end when the user is not logged-in. This is causing some issues with certain themes and plugins which make AJAX calls on the front-end.

Workaround

The issue has been resolved in WPML 3.7.0.

To enable language information in front-end AJAX calls, go to WPML > Languages then scroll down until you see “Language filtering for AJAX operations”.

There you will find the “Store a language cookie to support language filtering for AJAX”:


What follows is the workaround for WPML 3.6.3:

If you are experiencing this issue and you are not using any caching plugin you can use the following workaround:

  1. Edit the sitepress-multilingual-cms/classes/utilities/class-wpml-cookie.php file.
  2. Change the set_cookie function

from:

public function set_cookie( $name, $value, $expires, $path, $domain ) {
   if ( $this->should_set_cookie() ) {
      setcookie( $name, $value, $expires, $path, $domain );
   }
}

To:

public function set_cookie( $name, $value, $expires, $path, $domain ) {
   setcookie( $name, $value, $expires, $path, $domain );
}

12 Responses to “Unable to get site language on the front-end ajax calls when user is not logged-in”

  1. Hello
    An installation for me really difficult impossible to translate the theme thank you for gives me the link of the technical support(medium) or I can give you screenshots or I can have answers.
    I am lost with thousands of texts explanation I deny understands(includes) nothing more for me his(her,its) become a big person(main part) taken of sucked installation.
    Email address j.jarry1990@laposte.net
    Cordially

    • Hi Alexandre,

      Good, thanks for letting us know! We’ve made some changes in the way we store cookies and fixed this problem, we will publish this on next release.

      • Hello Adriano

        The workaround on this page helped me fix a strangeproblem with flatsome and the “quick view”.

        Although on the latest version of WPML (updated 2017-04-18), thie problem is back, and the file sitepress-multilingual-cms/classes/utilities/class-wpml-cookie.php is gone.

        Can this fix be applied again somehow?

        • Hello Martin,

          Can you please check the comments below from Emmanuel?

          Could it be that you need to select the “Language filtering for AJAX operations” option as well?

          You can find it by going to WPML > Languages, then, scroll at the bottom: you must see a “Language filtering for AJAX operations” section, where you can enable this option.

  2. Hello,

    This workaround worked fine in the previous version. I am now using the 3.7.0 version, and this issue appears again.

    Thanks for your help.

  3. Thanks!! 🙂

    The same was for me, after latest update my problem was back (total price for an apartment at the last step of booking goes to 0€ after 1sec, for all languages except ENG), but after selecting this option at the bottom of WPML/Language , all is OK again.

    Thanks once again. 😉