This thread is resolved. Here is a description of the problem and solution.
Problem: The client is experiencing a 301 error (Too many redirects) when trying to view all translated products on their website. They are unsure if recent plugin updates could have caused this issue. Solution: We identified that the issue was related to the handling of taxonomy slugs for product categories. We recommended modifying the code to ensure that the slug for each product category is correctly decoded. Here is the code we suggested adding to the site's functions:
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. Additionally, you can open a new support ticket for further assistance 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.
Background of the issue:
I am trying to view translated products on my site, but I suddenly encounter an issue. Nothing has been changed on the site or server, except for current plugin updates. The issue can be seen on this page:
hidden link
Symptoms:
I am experiencing a 301 error (Too many redirects) when trying to view all translated products.
Questions:
Why am I getting a 301 error on translated products?
Could recent plugin updates have caused this issue?
After a research I found out that the problem occurs when I update the woocommerce from 9.4.3 to 9.5.1. In 9.4.3 everything works. I use a plugin to rollback the version. I also used your solution ("Save" button to flush the permalinks cache) but this didn't solve the problem. Now I have woocommerce 9.4.3 so everything is ok but I will need to update...
Hi, Thank you, so would you please copy your website to a staging version so I can do troubleshooting without the fear of changing something wrong on a live website and get back to us with the login info?
Please set the next reply as private.
I will take a look at that.
Beforehand, you can follow the steps below:
- IMPORTANT STEP! Create a backup of your website. Or better approach will be to test this on a copy/staging version of the website to avoid any disruption of a live website.
- Switch to the default theme such as "TwentyTwenty" by going to "WordPress Dashboard > Appearance > themes".
- Go to "WordPress Dashboard > Plugins" and deactivate all plugins except Woocommerce, WPML and its add-ons.
- Check if you can still recreate the issue.
- If not, re-activate your plugins one by one and check the issue each time to find out the plugin that causes the problem.
I checked but the problem is that after the woocommerce has been updates the link for a product becomes hidden link... and before the update was hidden link
I tried to change the custom base from /gold-jewelry/%product_cat%/ το /χρυσά-κοσμήματα/%product_cat%/ but then the redirection error occurs.
If you check the url of a translated product before woocommerce update you will notice that the url starts with hidden link
As soon as i try to edit the translated url the problem occurs
I have rolled back to the previous woocommerce. Feel free to check/update again.
In short I need the custom base to be from /gold-jewelry/%product_cat%/ το /χρυσά-κοσμήματα/%product_cat%/ without the redirection error
Thank you very much. I replicated the issue on a clean installation:
hidden link
The problem is reported to the second tier support and they will follow up with the development team.
This might take time, I suggest that you wait for a new release of the Woocommerce Multilingual and Multi-currency plugin before updating Woocommerce.
Also FYI, the issue happens only with a translation of non English characters. So if you use the English characters in the translation of the Product base it will work ok.
I will help you further on this issue, as Christopher is on vacation.
After further debugging, we observed that the issue persists even without WPML when the default language is set to Greek and the category slug is translated. However, if the category slug is not in Greek, the issue does not occur.
To address this, I have found a workaround. You can add the following code to your theme’s `functions.php` file:
add_filter( 'wc_product_post_type_link_product_cat', function( $category_object, $terms, $post ) {
// Ensure the term object is valid
if ( isset( $category_object->slug ) ) {
// Decode the slug to Unicode
$category_object->slug = urldecode( $category_object->slug );
}
return $category_object;
}, 10, 3 );
Feel free to login and update the woocommerce plugin yourself to check it. Just roll back the plugin when you finish (if you have not found a solution)