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:
add_filter( 'get_term', function( $term, $taxonomy ) { if ( $taxonomy === 'product_cat' && isset( $term->slug ) ) { $term->slug = urldecode( $term->slug ); } return $term; }, 10, 2 );
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.
Tagged: WCML
Related documentation:
This topic contains 2 replies, has 0 voices.
Last updated by Shekhar Bhandari 1 week, 2 days ago.
Assisted by: Shekhar Bhandari.
Author | Posts |
---|---|
December 20, 2024 at 9:44 pm #16535517 | |
thodorisS |
Background of the issue: hidden link Symptoms: Questions: |
December 22, 2024 at 9:07 am #16537317 | |
Christopher Amirian Supporter
Languages: English (English ) Timezone: Asia/Yerevan (GMT+04:00) |
Hi, Welcome to WPML support. I checked your website and I see the translation with no issues. (Please check the screenshot) I suggest that you do as follows: - Go to "WordPress Dashboard > Settings > Permalinks". After that clear your browser cache. Thanks |
December 24, 2024 at 5:36 pm #16544392 | |
thodorisS |
Hello, 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... |
December 25, 2024 at 9:33 am #16545125 | |
Christopher Amirian Supporter
Languages: English (English ) Timezone: Asia/Yerevan (GMT+04:00) |
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. Thanks. |
December 29, 2024 at 1:43 pm #16551257 | |
Christopher Amirian Supporter
Languages: English (English ) Timezone: Asia/Yerevan (GMT+04:00) |
Hi, Thank you for the login information. I updated the Woocomemrce plugin and cleared the permalinks cache. What I see is that the way now the categories and the single product works is as follows: hidden link That is what you added in WordPress Dashboard > Settings > Permalinks > Products Permalinks (Check the screenshot) So you will need to use that method or if you want to change the way URLs work you can change the base URL there. |
December 29, 2024 at 4:13 pm #16551467 | |
thodorisS |
Hello, 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 Kind Regards |
December 30, 2024 at 9:02 am #16552442 | |
Christopher Amirian Supporter
Languages: English (English ) Timezone: Asia/Yerevan (GMT+04:00) |
Hi, 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. Thanks. |
December 31, 2024 at 7:49 am #16555043 | |
Shekhar Bhandari Supporter
Languages: English (English ) Timezone: Asia/Kathmandu (GMT+05:45) |
Hello, 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 ); Please let me know if this resolves the issue. Thanks! |
December 31, 2024 at 11:00 am #16555479 | |
thodorisS |
Dear Shekhar, Thank you for your help and for your time. I tried your solution (code snipset to my theme's functions.php) but I am getting the same error (301) after updating woocommerce. Kind Regards |
December 31, 2024 at 11:14 am #16555511 | |
Shekhar Bhandari Supporter
Languages: English (English ) Timezone: Asia/Kathmandu (GMT+05:45) |
Hello there, I just checked this url and it worked for me, hidden link Can you clear the cache and check? Look forward to your reply. Thanks |
December 31, 2024 at 12:00 pm #16555673 | |
thodorisS |
Yes it is working because I rolled back woocommerce to 9.4.3 |
December 31, 2024 at 12:00 pm #16555674 | |
Shekhar Bhandari Supporter
Languages: English (English ) Timezone: Asia/Kathmandu (GMT+05:45) |
Hello there, Can you update it so I can check? Thanks |
January 1, 2025 at 5:18 pm #16557345 | |
thodorisS |
Dear Shekhar, 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) Kind Regards |
January 2, 2025 at 4:54 am #16557675 | |
Shekhar Bhandari Supporter
Languages: English (English ) Timezone: Asia/Kathmandu (GMT+05:45) |
Hello there, The custom filter was not working on your context as the post has clild categories. I modified the code as below to filter all taxonomy slug and it's working add_filter( 'get_term', function( $term, $taxonomy ) { if ( $taxonomy === 'product_cat' && isset( $term->slug ) ) { $term->slug = urldecode( $term->slug ); // Modify slug for all product categories } return $term; }, 10, 2 ); Let me know if this helps. Thanks |
January 2, 2025 at 12:17 pm #16558799 | |
thodorisS |
Dear Shekhar, Thank you for your time and Happy new year!! It looks like the problem has been solved using your solution. Do you think its a Woocommerce or a WPML thing (just asking). Thnaks again Kind Regards |