Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 -
- 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 14 replies, has 2 voices.

Last updated by Long Nguyen 2 years, 2 months ago.

Assisted by: Long Nguyen.

Author Posts
March 8, 2023 at 12:12 pm #13198629

majdA-6

I am having a strange issue with translating store URLs.

I have a Woocommerce site with English as default language. I am translating it to Swedish.

But when I try to visit the cart page in the translated front-end, I get a 404 error with "Sorry, no posts found" error message.

I believe the issue is related to product permalinks. I once downgraded the site to PHP 8.0 (from 8.1), and had to re-save the product permalinks (in settings > permalinks).

But it seems this did not resolve all issues.

When I try to translate the shop page (under WooCommerce > WooCommerce Multilingual & Multicurrency > Store URLs), and change the current translation of the shop page to something else (currently it is translated to: produkter), for example to produkter-2, then it works and I can visit cart and checkout page.

March 9, 2023 at 3:41 am #13203047

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi there,

Thank you for contacting WPML support, I'd be happy to help you with this issue.

According to the log chat, I think it is a conflicting slug issue. The slug "produkter" could be used somewhere else on your site. You can follow the documentation below to find the slug
https://wpml.org/documentation/getting-started-guide/string-translation/finding-strings-that-dont-appear-on-the-string-translation-page/

If it does not help, please create a full backup of your site with the plugin Duplicator and share the backup file with me, I will try to restore your site on my local host and take a look. Your next reply is set to private to share the info.
You can use this plugin to create the backup: 
https://wordpress.org/plugins/duplicator/

You can also read more about WooCommerce product base here https://woocommerce.com/document/permalinks/#section-3

Look forward to your reply.
Thanks

March 10, 2023 at 2:22 am #13212839

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Thank you for your feedback.

I also think about the conflicting slug issue. To prevent this, I recommend changing the slug:

- Shop page: EN: "products" - SV: "produkters"
- Product base: EN: "product" - SV: "produkter"

Then the cart works correctly on the frontend.

Look forward to your reply.
Thanks

March 10, 2023 at 8:18 am #13214347

majdA-6

Hi, that doesn't make any sense. I already know if I did that it will work.

But in my WooCommerce permalink settings I have set the default product permalink base to be SHOP base (view uploaded image). This works fine in default language. I dont have it setup as you wrote with "product" as product base and "products" as shop base, I have "products" for both.

This displays correct breadcrumb hierarchy when visiting a product page and is better for UX and probably SEO.

I only start having issues when I start translating. I don't understand why I can't have same product permalink base hierarchy structure for translated languages aswell. I think you need to send this to higher tier support for clarification on this issue and why this is not working.

Because, this is possible per WooCommerce default settings without issues.

product_base.png
March 13, 2023 at 2:35 am #13227513

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Thank you for your feedback.

I see the issue happens when the cart page is a child page of the shop (products) page. If you set the cart as a top page, this issue does not happen.

I'm also asking my 2nd tier support about this issue and I will update you here when I have something to share.

Thanks.

March 20, 2023 at 1:58 pm #13285049

majdA-6

Hello again,

Are you able to provide any updates on this issue?

March 21, 2023 at 1:40 am #13288931

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Thank you for your feedback.

This is a very edge case with WPML and WooCommerce. I got a workaround from the 2nd tier support, please check this below.

❌ IMPORTANT: Please backup your database and website before proceeding ❌

- Go to the file wp-content/plugins/wpml-string-translation/classes/slug-translation/class-wpml-rewrite-rule-filter.php

- Around line 56, after the code

foreach ( $this->custom_types_repositories as $repository ) {
	$types[] = $repository->get();
}

add this code

if (strpos( $_SERVER["REQUEST_URI"] ,"varukorg" ) !== false) {
	$types[] = "page";
}

But it would throw a PHP warning, you might need to turn off the WP debug, please read more on the documentation https://wordpress.org/documentation/article/debugging-in-wordpress/

The development team still investigate the issue, you can apply the workaround again if the next update does not include the fix for the issue.

Thanks for your patience.

March 22, 2023 at 8:28 am #13301471

majdA-6

Hi,

Thank you but it didn't work. It threw a fatal error actually when visiting the cart page:

Fatal error: Uncaught TypeError: array_merge(): Argument #3 must be of type array, string given in C:\Users\Majd\Local Sites\vali-co-2\app\public\wp-content\plugins\wpml-string-translation\classes\slug-translation\class-wpml-rewrite-rule-filter.php:64 Stack trace: #0 C:\Users\Majd\Local Sites\vali-co-2\app\public\wp-content\plugins\wpml-string-translation\classes\slug-translation\class-wpml-rewrite-rule-filter.php(64): array_merge(Array, Array, 'page') #1 C:\Users\Majd\Local Sites\vali-co-2\app\public\wp-content\plugins\wpml-string-translation\classes\slug-translation\class-wpml-rewrite-rule-filter.php(30): WPML_Rewrite_Rule_Filter->get_custom_types() #2 C:\Users\Majd\Local Sites\vali-co-2\app\public\wp-content\plugins\wpml-string-translation\classes\slug-translation\RewriteRules\Hooks.php(52): WPML_Rewrite_Rule_Filter->rewrite_rules_filter(Array) #3 C:\Users\Majd\Local Sites\vali-co-2\app\public\wp-includes\class-wp-hook.php(310): WPML\ST\SlugTranslation\Hooks\Hooks->filter(Array) #4 C:\Users\Majd\Local Sites\vali-co-2\app\public\wp-includes\plugin.php(205): WP_Hook->apply_filters(Array, Array) #5 C:\Users\Majd\Local Sites\vali-co-2\app\public\wp-includes\option.php(253): apply_filters('option_rewrite_...', Array, 'rewrite_rules') #6 C:\Users\Majd\Local Sites\vali-co-2\app\public\wp-includes\class-wp-rewrite.php(1486): get_option('rewrite_rules') #7 C:\Users\Majd\Local Sites\vali-co-2\app\public\wp-includes\class-wp.php(163): WP_Rewrite->wp_rewrite_rules() #8 C:\Users\Majd\Local Sites\vali-co-2\app\public\wp-includes\class-wp.php(780): WP->parse_request('') #9 C:\Users\Majd\Local Sites\vali-co-2\app\public\wp-includes\functions.php(1332): WP->main('') #10 C:\Users\Majd\Local Sites\vali-co-2\app\public\wp-blog-header.php(16): wp() #11 C:\Users\Majd\Local Sites\vali-co-2\app\public\index.php(17): require('C:\\Users\\Majd\\L...') #12 {main} thrown in C:\Users\Majd\Local Sites\vali-co-2\app\public\wp-content\plugins\wpml-string-translation\classes\slug-translation\class-wpml-rewrite-rule-filter.php on line 64

Please continue investigate the issue. I don't think it is a "edge" case and I am surprised not more people have reported this since it is normal to set shop base to same in product permalinks. I initially thought it was specific to my site. It's also supported on default woocommerce settings.

And please also keep me updated, I am about to finish this project and would like this solved.

March 22, 2023 at 9:04 am #13301899

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Thank you for your feedback.

It looks like you are testing the code in the local host, can you please share a screenshot of the custom code added to the file wp-content/plugins/wpml-string-translation/classes/slug-translation/class-wpml-rewrite-rule-filter.php?

I've tested to apply the code on your sandbox site and it works correctly. Please check this screenshot hidden link

Look forward to your reply.
Thanks

March 22, 2023 at 9:20 am #13302269

majdA-6

Sure, view attached.

custom_code.png
March 22, 2023 at 10:58 am #13303719

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Thanks for your feedback.

It looks like you are using PHP 8.0 or higher, please try to downgrade it to 7.4 and check this issue again.

Look forward to your reply.
Thanks

March 22, 2023 at 11:32 am #13304185

majdA-6

Hi,

I don't really want to do that. I want my site running on PHP 8.+.

March 23, 2023 at 1:23 am #13309873

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Thank you for your feedback.

As I mentioned above, there is a PHP warning when using the workaround. But unfortunately, it will break the site with PHP 8+. I'm asking my colleague to take a deeper look at this issue and I will update you here once I have something to share.

Thanks for your patience.

April 4, 2023 at 11:14 am #13399099

majdA-6

Hello again, has there been any progress to this issue?

April 5, 2023 at 1:06 am #13404789

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Thank you for your feedback.

Currently, we have a workaround for PHP 7.4 only. For PHP 8, please wait for a proper fix from our developer. I will update you here once I have any information.

Regards.