Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client was experiencing an issue where category names were displayed in different languages on a WooCommerce site with Redis Cache enabled. This occurred when the product was translatable and set to 'use translation if available or fallback to default language', and the product did not have a translation.

Solution:
We provided a workaround involving the insertion of custom PHP code into the theme's functions.php file. This code ensures that when Redis Cache is enabled, the correct language for product terms is used.

<!-- Custom PHP code provided by WPML support --><br />add_filter('woocommerce_get_product_terms', function($terms, $product_id, $taxonomy, $args){<br />    global $sitepress;<br /><br />    if (method_exists($sitepress, 'is_display_as_translated_post_type') && $sitepress->is_display_as_translated_post_type('product')) {<br />        $args['wpml_lang'] = apply_filters( 'wpml_current_language', null );<br />        return _wc_get_cached_product_terms( $product_id, $taxonomy, $args );<br />    }<br /><br />    return $terms;<br />}, 10, 4);<br />

If this solution does not seem relevant to your situation, please do not hesitate to open a new support ticket with us.

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.

Tagged: 

This topic contains 21 replies, has 2 voices.

Last updated by Kor 1 year, 5 months ago.

Assisted by: Kor.

Author Posts
November 20, 2023 at 4:22 pm #14879469

kristianP-7

I am trying to: enable Redis Cache on fresh installation of wordpress and woocommerce to show a bug I found.

Link to a page where the issue can be seen: hidden link
password: parool

I expected to see: category names in one language

Instead, I got: category names in different languages

wpml support 1.png
Screenshot_2.png
November 23, 2023 at 9:24 am #14905363

Kor
WPML Supporter since 08/2022

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Hi there,

Thanks for contacting WPML support.

I will need to closely examine your website. Therefore, I will require temporary access (WP-Admin and FTP) to a test site where the problem has been replicated, if possible. This will enable me to provide better assistance and determine if any configurations need to be modified.

Please note that it is important to have a backup for security purposes and to prevent any potential data loss. You can use the UpdraftPlus plugin (https://wordpress.org/plugins/updraftplus/) to fulfill your backup requirements.

Your upcoming reply will be treated with confidentiality and will only be visible to you and me.

✙ To resolve the issue, I may need your consent to deactivate and reactivate plugins and the theme, as well as make configuration changes on the site if necessary. This emphasizes the significance of having a backup.

Also, I noticed that your “WP Memory Limit” PHP limit is below the required 128MB or recommended 256MB as described at: https://wpml.org/home/minimum-requirements/ . Could you please contact your hosting provider and ask them to increase this PHP value for yousc and also, ask them to update the MySQL version to 5.6+?

November 28, 2023 at 6:53 pm #14943693

Kor
WPML Supporter since 08/2022

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your reply.

The attached is what I'm getting on my end. Does it happen randomly?

Screenshot_360.png
Screenshot_361.png
November 28, 2023 at 10:50 pm #14945005

kristianP-7

You are seeing the same as me (the right-most category in breadcrumbs is in wrong language).

It's not random, it only happens when:
1. redis cache is enabled
2. when product is translatable and "use translation if available or fallback to default language"
3. when product does not have translation

Also it's reversed when you flush object cache and view it first in English language.
Then it will show Kategooria1>Kategooria2>Category3

And when flushing cache and viewing Estonian first then it will show like:
Category1>Category2>Kategooria3

products translatable.png
November 29, 2023 at 5:17 pm #14954419

Kor
WPML Supporter since 08/2022

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your patience.

We apologize for the inconvenience, but in order to proceed with troubleshooting, we kindly request a site snapshot. Alternatively, with your permission, we can create a snapshot on our own.

For this purpose, we typically recommend using the free plugin "Duplicator." If you are already familiar with how Duplicator works ( https://wordpress.org/plugins/duplicator/), please skip the following steps and simply send me the archive file you downloaded.

To assist you further, please follow these instructions:
Watch the Duplicator instructions video: hidden link

Refer to the instructions provided by WPML on how to provide supporters a copy of your site: https://wpml.org/faq/provide-supporters-copy-site/

If the archive file exceeds 400MB in size, please utilize Duplicator's file filters to exclude the cache, wp-uploads directory, media, and archive files.

Once you have the archive file, please share the link with us. You can use services such as Google Drive, Dropbox, or similar platforms as the snapshot file will likely be large.

Please note that your next reply will be private, visible only to you and me. You can paste the link to the file there. Rest assured that once the issue is resolved, I will delete the local site.

December 4, 2023 at 8:56 am #14983321

Kor
WPML Supporter since 08/2022

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thank you for your understanding.

I'm sorry for the delay in getting back to you. I've successfully imported your website into my local development environment, but unfortunately, I couldn't the "Redis Object Cache" plugin to work as shown in the attached screenshot. Sorry, I'm not very familiar with the settings of this particular plugin.

To further investigate the issue and potentially escalate it if necessary, I've set up a sandbox site here hidden link . Could you please install the necessary plugins and attempt to replicate the problem there? This will help us better understand and address the issue.

Screenshot_384.png
December 4, 2023 at 3:07 pm #14988513

kristianP-7

Hello!

Redis should be installed and configured on the server. It's usually not included with cheaper webhosts and I'm afraid I can't set it up on the sandbox site.
You can create redis server locally on any machine by following this guide: hidden link.

After you have redis server up and running you can configure wp-config.php in htdocs folder like I've done on staging.kylmakeskus.ee as seen on the attached screenshot.

Redis cache is very helpful at caching wordpress backend queries and making backend more faster and efficient and is crucial for larger sites.

Best regards

redis config.png
December 5, 2023 at 10:41 am #14995653

Kor
WPML Supporter since 08/2022

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your reply.

Sorry, I don't think we have a redis configuration on the server. Can we work on your staging site directly? If you agree, I will forward your login information to our 2nd Tier Support for further investigation.

December 5, 2023 at 8:10 pm #15002557

kristianP-7

Yes, you can work on the staging site directly.

December 6, 2023 at 7:19 pm #15011791

Kor
WPML Supporter since 08/2022

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your reply.

I've just escalated this to our 2nd Tier Support and I will come back to you once I have feedback.

December 13, 2023 at 2:28 pm #15056027

Kor
WPML Supporter since 08/2022

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your patience.

I received a response from our 2nd Tier Support and he suggested the workaround below. Please let me know how it goes.

Workaround 1:
Add this to functions.php:

add_action( 'wpml_st_before_remove_strings', 'wp_cache_flush' );

Workaround 2:
Try the script here https://wpml.org/forums/topic/object-cache-pro-causing-wpml-issues/page/2/#post-14302565

December 14, 2023 at 12:56 am #15060103

kristianP-7

I tried both of the workarounds on staging.kylmakeskus.ee but the issue is still there :/

December 14, 2023 at 6:52 pm #15068193

Kor
WPML Supporter since 08/2022

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your reply.

I've shared your feedback with our 2nd Tier Support. They will recheck and I will update you once I hear from them.

December 19, 2023 at 1:15 am #15088091

Kor
WPML Supporter since 08/2022

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your reply.

Could you please try mu-plugin method again and add group "posts" to it? Please let me know if this works.

December 23, 2023 at 2:29 am #15122007

kristianP-7

Adding posts fixed the problem on staging site, but live site somehow is still facing that issue..

I added the same wordpress theme to staging.kylmakeskus.ee website aswell so you can take a look. The problem is that the theme is using it's own custom breadcrumbs widget I think and that's why it's still not working correctly.