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 Raja Mohammed 7 months, 2 weeks ago.

Assigned support staff: Raja Mohammed.

Author Posts
March 3, 2019 at 1:14 pm #3266210

richardH-41

We're running WPML + Woocommerce.

I've been struggling with this issue for months where randomly 404's are generated for product category pages. Re-saving permalinks resets the issue and the site continues to hum along until it doesn't, repeatedly. I can't replicate the 404's occurring directly, but stopping flush_rewrite_rules from running causes it to happen immediately.

We had the site set up using the ?lang= parameter, but thought we might change that to the sub-folder to try and stop the above issue from occurring again - but it still is. Once we did this change the .htaccess file was changing on every request and breaking everything.

We're setup as EN being normal path structure and other languages as a sub-folder.

Tonight I was exploring the code and this issue once again and discovered that every page request is calling a flush_rewrite_rules.

Looking at the rewrite_rules option value, it's essentially changing to whatever the last language request was. (eg en, fr, es etc - we're running 8 languages), so it appears that the re-write rules are only ever dealing with one language at a time which explains why the flush keeps occurring because it's not matching - so it forces a re-flush.

Why would this be the case? Have I not set something correctly?

Doing a backtrace on the flush_rewrite_rules function call, it's coming from the woocommerce-multilingual plugin.

* woocommerce-multilingual/inc/class-wcml-endpoints.php LINE 167
* woocommerce-multilingual/inc/class-wcml-endpoints.php LINE 21
* woocommerce-multilingual/classes/class-woocommerce-wpml.php LINE 222

This backtrace points to the flush_rules_for_endpoints_translations option having a boolean value (maybe_flush_rules only does something if the other has the boolean true value).

The 404 only then being generated when the flush doesn't occur for a specific request, breaking everything and no longer flushing the rewrite rules (in whatever unknown so far scenario)

I'm pulling my hair out and it's fustrating for my client who keeps getting 404's. This site gets ~1400+ visitors a day, so I really need to get this issue resolved.

Thankyou.

March 5, 2019 at 10:30 am #3272768

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi there,

Sorry about your situation.

It seems you are using an older version of WPML and WooCommerce Multilingual. Please update to the latest version. Most of the issue including 404 error in categories are solved in the latest version of WPML. Please update and check whether you can reproduce the issue again. Make sure you flush all caches and test the site in a browser with cookies and caches cleared.

Since you have a quite a bit older version of WPML we highly recommend you to back up your site and database before proceeding with the update.

Let me know the results.

Kind regards
Raja

March 5, 2019 at 11:48 am #3273504

richardH-41

Hello Raja

The issue continued - I looked a bit further, and decided to deactivate the "Premmerce WooCommerce Permalink Manager Lite" plugin.

It allows us to have a simpler URL (hidden link instead of the much longer version that is the standard - hidden link)

Once I did that, the direct category longer version urls all work fine under each translation.

So, it appears plugin updates solved some but Premmerce being the main culprit not able to do deal with WPML correctly...

March 5, 2019 at 11:55 am #3273568

richardH-41

Just FYI - just came across this:-
https://wordpress.org/support/topic/premmerce-wpml-404-secondary-language/

March 5, 2019 at 12:14 pm #3273710

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

Thanks for the update, Glad you are now able to achieve some process.
Seems you have identified the issue here is a thread from a client with similar problem https://wpml.org/forums/topic/product-category-slug-removal-works-in-one-language-only/

Kindly check with the plugin author for any solution. Or you can ask the plugin author to contact us to make the plugin compatible with WPML we will be happy to cooperate.

Kind regards
Raja