This thread is resolved. Here is a description of the problem and solution.
Problem:
If you're experiencing a fatal error on your shop page while searching, which results in a PHP error related to 'Call to a member function get_id() on bool', this might be due to an issue in the WooCommerce Multilingual plugin.
Solution:
We recommend you try the following steps after ensuring you have a full site backup:
1) Navigate to the
wp-content\plugins--woocommerce-multilingual\inc
folder.
2) Open the
class-wcml-comments.php
file for editing.
3) Scroll down to line 109.
4) Replace the existing code block with the following updated code:
From
foreach ( $translations as $translation ) { $product = wc_get_product( $translation ); $ratings = WC_Comments::get_rating_counts_for_product( $product ); $review_count = WC_Comments::get_review_count_for_product( $product ); if ( is_array( $ratings ) ) { foreach ( $ratings as $rating => $count ) { $average_ratings_sum += $rating * $count; $average_ratings_count += $count; if ( isset( $ratings_count[ $rating ] ) ) { $ratings_count[ $rating ] += $count; } else { $ratings_count[ $rating ] = $count; } } } if ( $review_count ) { $reviews_count += $review_count; } else { update_post_meta( $translation, self::WCML_AVERAGE_RATING_KEY, null ); update_post_meta( $translation, self::WCML_REVIEW_COUNT_KEY, null ); update_post_meta( $translation, self::WCML_RATING_COUNT_KEY, null ); } }
To
foreach ( $translations as $translation ) { $product = wc_get_product( $translation ); if ($product) { $ratings = WC_Comments::get_rating_counts_for_product( $product ); $review_count = WC_Comments::get_review_count_for_product( $product ); if ( is_array( $ratings ) ) { foreach ( $ratings as $rating => $count ) { $average_ratings_sum += $rating * $count; $average_ratings_count += $count; if ( isset( $ratings_count[ $rating ] ) ) { $ratings_count[ $rating ] += $count; } else { $ratings_count[ $rating ] = $count; } } } if ( $review_count ) { $reviews_count += $review_count; } else { update_post_meta( $translation, self::WCML_AVERAGE_RATING_KEY, null ); update_post_meta( $translation, self::WCML_REVIEW_COUNT_KEY, null ); update_post_meta( $translation, self::WCML_RATING_COUNT_KEY, null ); } } }
5) Clear all types of caches.
Please note, this issue has been escalated to our developers for further investigation and resolution.
If this solution does not resolve your issue, or if it seems outdated or irrelevant to your case, we highly 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 needed, 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 is split from https://wpml.org/forums/topic/wpml-plugin-alters-the-search-queries/