Resolved

Reported for: WooCommerce Multilingual 4.0.4

Resolved in: WooCommerce Multilingual 4.1.0

Symptoms

If you are using an older version of WPML – for example 3.4.0, and you update from WooCommerce Multilingual 4.0.3 to 4.0.4 you might get a fatal error similar to the following:

"PHP Fatal error: Call to undefined method WPML_WP_API::is_comments_post_page() in /wp-content/plugins/woocommerce-multilingual/inc/wcml-switch-lang-request.php on line 136"

Workaround

There are two ways to fix this problem:

1. Update WPML to the latest version – this is the recommended, fastest and safest way.

2. Use the following code to patch and replace the get_requested_lang() function in the /woocommerce-multilingual/inc/wcml-switch-lang-request.php file.

public function get_requested_lang() {

       return $this->is_comments_post_page() ? $this->get_cookie_lang() : $this->get_request_uri_lang();
   }

   public function is_comments_post_page() {
       global $pagenow;

       return 'wp-comments-post.php' === $pagenow;
   }