This thread is resolved. Here is a description of the problem and solution.
Problem:
If you're experiencing a fatal error when switching languages on a product category page, specifically with the error message 'Fatal Error Illegal offset type in isset or empty' in
/wp-content/plugins/sitepress-multilingual-cms/classes/core-abstract-classes/class-wpml-element-translation.php:282
, we have identified a solution that does not require modifying the WPML plugin.
Solution:
The issue arises from a piece of code in
wp-content/themes/shopkeeper-child/woocommerce/archive-product.php
that retrieves a term named 'prod-cat__msg_banner'. The error occurs because the value returned is interpreted as an array with a blank element. Here are two solutions:
1. No code: Change the value in the database for the term ID to not be a serialized value. You can reference the original term ID 1135 to see how it is saved.
2. Using code: In
wp-content/themes/shopkeeper-child/woocommerce/archive-product.php
at line 316, after the code:
if (!empty($msg_banner)) { global $wp_query; }
add:
if (is_array($msg_banner)){ $msg_banner = $msg_banner[0]; }
Please test any of the solutions after making a full backup and let us know the results.
If this solution does not resolve your issue or seems outdated, we recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket at WPML support forum.
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 4 replies, has 2 voices.
Last updated by 6 months ago.
Assisted by: Mateus Getulio.