Skip Navigation
Updated
October 11, 2021

WooCommerce Multilingual and some themes and plugins need to run AJAX calls on the front-end based on language information. For this purpose, you may need to enable a language cookie that supports AJAX filtering.

To enable language information for the front-end AJAX calls, go to WPMLLanguages and scroll down to the Language filtering for AJAX operations section. There, check the Store a language cookie to support language filtering for AJAX option.

Enabling the language cookie that supports AJAX filtering on the front-end
Enabling the language cookie that supports AJAX filtering on the front-end

Now, WPML will set a cookie using JavaScript which allows it to return the correct content for AJAX operations.

This is how this works for visitors:

  • For users that are logged-in, nothing changes and this setting is not applied. Language cookie is saved normally using PHP.
  • For users that are not logged-in, WPML checks if this setting is turned on and if so, the language cookie is set using JavaScript. This allows WPML to set the language cookie even if the site is cached.

If you use WPML 4.5 or later, this setting is enabled by default. If you notice it interferes with your caching plugin, you can disable it by following the same steps as detailed above.